brilliant sunshine outside the high court in Washington for the historic rulings, which will have a major impact on US society.
In a 5-4 decision, the court first struck down the Defense of Marriage Act (DOMA), which denied federal benefits to married gay and lesbian couples by strictly defining marriage as a union between a man and a woman.
"DOMA is unconstitutional as a deprivation of the equal liberty of persons that is protected by the Fifth Amendment" of the Constitution, said the majority opinion written by Justice Anthony Kennedy.
President Barack Obama hailed the DOMA decision, saying in a statement: "We are a people who declared that we are all created equal -- and the love we commit to one another must be equal as well."
The court also said a case on Proposition 8, a 2008 voter initiative in California that prohibited same-sex marriage in the nation's most populous state, was not properly before them.
That 5-4 decision -- which indicated gay marriages would likely resume in California -- enabled the justices to dodge the thornier issue of whether same-sex marriage is a constitutional right throughout the United States.
Twelve US states plus the District of Columbia now recognize same-sex marriage, but about 30 states have decreed that marriage can only exist between a man and a woman.
"Now we will be married and be equal to every other family in California," said Kris Perry, a plaintiff in the Proposition 8 case, alongside her partner Sandy Stier on the Supreme Court steps.
"Thank you to the Constitution ... but it's not enough," added Stier. "It's got to go nationwide. This can't wait decades" for marriage equality to be legalized in all 50 states.
Obama, who left Washington for a tour of Africa just an hour before the rulings were issued, is the first serving US president ever to come out publicly in favor of marriage equality.
But there was outrage among social conservatives.
"The DOMA ruling has now made the normalization of polygamy, pedophilia, incest and bestiality inevitable," said Bryan Fischer, director of issue analysis at the American Family Association.
"With the DOMA decision, we have ceased to be a constitutional republic," he said on his Twitter feed.
Fifty-three percent of Americans say same-sex marriage should be legally recognized, according to a Gallup survey in May that echoed a string of similar findings by other polling organizations.
The fight against DOMA was spearheaded by Edith Windsor, a New Yorker hit with a $363,000 estate tax bill after the 2009 death of her lifelong partner Thea Spyer, who she had married in Canada.
Had the couple been straight, the tax bill would have been significantly reduced.
DOMA denied married gay and lesbians a raft of federal benefits that straight couples take for granted, from tax breaks to family hospital visits and the ability to sponsor a spouse for a residence visa.
Prior to Wednesday's rulings, law professor David Cruz of the University of Southern California said it was unlikely the Supreme Court would adopt a broad ruling that struck down all bans on same-sex marriage across the nation.
"Seeing all same-sex couples being able to get married in every state is probably not going to happen immediately ... because of the tradition in the court: the Justices often move in steps, they rule incrementally," he said.
Obama said: "The laws of our land are catching up to the fundamental truth that millions of Americans hold in our hearts: when all Americans are treated as equal, no matter who they are or whom they love, we are all more free."