Image copyright Reuters Image caption Doma plaintiff Edith Windsor saluted her late partner Thea Speyer after the Supreme Court ruled in her favour Image copyright AFP Image caption Outside the Supreme Court in Washington DC as many as 1,000 people gathered to cheer the rulings Image copyright AP Image caption The Pentagon has said it will work to extend benefits to same-sex married couples in the military as quickly as possible Image copyright AP Image caption Gay marriage may soon be allowed in the state of California as a result of a second Supreme Court ruling on the state's ban, called Proposition 8 Image copyright Getty Images Image caption Gay marriage advocates have said the twin rulings represent a major victory Image copyright Getty Images Image caption Critics have said they are disappointed by the rulings and hope that individual states will write laws defining marriage as between a man and a woman only previous slide next slide

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.

'We are more free'

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.

At the scene Narrow victories perhaps, but there was evident delight among the overwhelming majority of those gathered in the hot sun outside the Supreme Court. After today, public and legal opinion are more closely aligned. No consensus yet, but narrow majorities in favour of gay couples being allowed to marry and enjoy the same rights as their fellow, straight citizens. The practical implications of today's rulings may be narrow (they only involve 13 states and the District of Columbia), but it was the symbolism of the moment that thrilled the crowd. They know there will be lots of battles ahead. But for the first time, the Supreme Court has attempted to make sense of the rules around gay marriage. For most of those who gathered in the heat outside this great temple of law, today's results suggest the tide of history is with them.

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'

Media playback is unsupported on your device Media caption In Washington DC people talked to the BBC about the rulings

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.

Media playback is unsupported on your device Media caption A military woman and her wife explain why Doma has made their life as a married couple difficult

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.