27 June 2013 Last updated at 01:53 GMT
Continue reading the main story
But the California ruling means that 13 US states and the District of Columbia now recognise same-sex marriage.'We are more free'
The US Supreme Court has struck down a law denying federal benefits to gay couples and cleared the way for same-sex marriage in California.
The justices said that the Defense of Marriage Act, known as Doma, discriminated against same-sex couples.
In a second ruling, they left in place a lower court's striking down of Proposition 8, California's prohibition of gay marriage.
Opinion polls indicate that most Americans support same-sex marriage.
Wednesday's decisions do not affect the bans on gay unions enshrined in the constitutions of 29 US states.
But the California ruling means that 13 US states and the District of Columbia now recognise same-sex marriage.
The Doma opinion grants legally married gay men and women access to the same federal entitlements available to opposite-sex married couples. These include tax, health and pension benefits and family hospital visits.
The landmark 5-4 rulings prompted celebrations from about 1,000 gay rights advocates gathered outside the Supreme Court in Washington DC and many more nationwide.
The legal challenge to Doma was brought by New York resident Edith Windsor, 84.
She was handed a tax bill of $363,000 (£236,000) when she inherited the estate of her spouse Thea Speyer - a levy she would not have had to pay if she had been married to a man.
"It's an accident of history that put me here," Ms Windsor said after the ruling was handed down.
"If I had to survive Thea, what a glorious way to do it. She would be so pleased."
Justice Anthony Kennedy wrote: "Doma writes inequality into the entire United States Code.
"Under Doma, same-sex married couples have their lives burdened, by reason of government decree, in visible and public ways," the decision added.
"Doma's principal effect is to identify a subset of state-sanctioned marriages and make them unequal."
Lower courts had also decided in Ms Windsor's favour.
After the ruling Defence Secretary Chuck Hagel said the Pentagon would begin extending benefits to same-sex military spouses as soon as possible.
Defence officials added there were an estimated 18,000 gay couples in the armed forces, although it is not known how many were married.
US President Barack Obama, who is on a state visit to the West African country of Senegal, said: "When all Americans are treated as equal, no matter who they are or whom they love, we are all more free."
But opponents of same-sex marriage said they were disappointed with the ruling.
"As the American people are given time to experience the actual consequences of redefining marriage," said Tony Perkins, president of the Family Research Council, "the public debate and opposition to the redefinition of natural marriage will undoubtedly intensify."'No authority'
Proposition 8 is a ban on gay marriage passed by California voters in November 2008, just months after the state's supreme court decided such unions were legal.
Two same-sex couples launched a legal challenge against Proposition 8. As the state of California refused to defend the ban on gay marriage, the group that sponsored Proposition 8 stepped up to do so.
On Wednesday, the US Supreme Court said a private party did not have the right, or "standing", to defend the constitutionality of a law, because it could not demonstrate it would suffer injury if the law were to be struck down and same-sex marriages allowed.
"We have no authority to decide this case on the merits," Chief Justice John Roberts wrote in the ruling, which was not split along ideological lines.
Their opinion leaves in place a ruling by a lower court, in San Francisco, that struck down Proposition 8.
California Governor Jerry Brown is ordering county officials across the state to comply. The San Francisco appeals court has said it will wait at least 25 days before allowing same-sex marriages to resume in California.
The four dissenting Supreme Court justices said they believed they should have addressed the constitutional question of same-sex marriage before them in the Proposition 8 case.
Further litigation could lie ahead for the California ban, analysts say.
President Obama called the plaintiffs to congratulate them from Air Force One, his official jet, en route to Africa.
About 18,000 same-sex couples were married in California in the less than five months same-sex marriages were permitted there.
Doma was signed into law in 1996 by former President Bill Clinton after it was approved in Congress with bipartisan support.
But it was subsequently struck down by several lower courts.
In 2011, President Obama said that while he would continue to enforce Doma, his administration would not defend it in court. So Republicans from the House of Representatives hired a lawyer to argue in favour of the measure.
House Speaker John Boehner, the top Republican in Congress, said he was disappointed with Wednesday's ruling.
"A robust national debate over marriage will continue in the public square, and it is my hope that states will define marriage as the union between one man and one woman," he said.