The US Supreme Court has extended federal benefits to married gay couples by striking down the Defence of Marriage Act (Doma) as uncostitutional in a groundbreaking 5-4 decision.
"Doma is unconstitutional as a deprivation of the equal liberty of persons protected by the Fifth Amendment," said the court.
"Doma writes inequality into the entire United States Code," Justice Anthony Kennedy wrote.
"Under Doma, same-sex married couples have their lives burdened, by reason of government decree, in visible and public ways," the ruling added.
"Doma's principal effect is to identify a subset of state-sanctioned marriages and make them unequal."
The same court issued a technical legal ruling that said nothing at all about same-sex marriage, but left in place a trial court's declaration that California's Proposition 8 is unconstitutional. That outcome probably will allow state officials to order the resumption of same-sex weddings in the nation's most populous state in about a month.
The nine judges of the Supreme Court were asked to rule on California's Proposition 8, which bans gay marriage, and on the constitutional standing of Doma, which stipulates that a legal marriage can only be between a man and a woman.
Proposition 8 banned gay marriage in 2008 just months after the state's high court allowed it. In the five-month period it was legal in California, about 18,000 same-sex couples got married in the state.
Two same-sex couples challenged the ban as unconstitutional and courts in California agreed. Defenders of Proposition 8 had asked for a Supreme Court ruling to overturn the decision by the California courts.
Doma, signed by then president Bill Clinton in 1996, essentially restricts benefits such as social security survivor payments and federal tax deductions to married and opposite-sex couples.
Earlier this year Clinton called for the law, which was approved by the vast majority of the Congress, to be reversed. Obama's administration initially defended it but in 2011 it was deemed unconstitutional by Attorney-General Eric Holder.
The Doma case heard by the Supreme Court centred on New York resident Edith Windsor who married Thea Spyer in a ceremony which was recognised under New York law but not under federal law.
In 2009, Spyer died and left everything to Windsor but the beneficiary was forced to pay federal estate taxes because she was not entitled to the deductions available to heterosexuals-only couples. She sued the government for $363,000 tax refund.
Polls show an increasing number of Americans supporting gay marriage but not evenly across the 50 states. Twelve states recognise same-sex marriage: Connecticut, Massachusetts, Delaware, Iowa, Rhode Island, Maine, Maryland, Washington, New Hampshire, Vermont, New York and Minnesota.