The US Supreme Court has handed a significant victory to gay rights advocates by recognising that married gay men and women are eligible for federal benefits and paving the way for same-sex marriage in California.
The court, however, fell short of a landmark ruling endorsing a fundamental right for gay people to marry.
The two cases, both decided on 5-4 votes, concerned the constitutionality of a key part of a federal law, the Defense of Marriage Act (DOMA), that denied benefits to same-sex married couples and a California state law enacted in 2008, called Proposition 8, which banned gay marriage.
Gay marriage advocates celebrated outside the courthouse. An enormous cheer went up as word arrived that DOMA had been struck down.
The court struck down the federal law as a violation of the US constitution's guarantee of equal protection under the law.
However, it ducked a ruling on Proposition 8 by finding that supporters of the law did not have standing to appeal a federal district court ruling that struck the law down.
While the ruling on DOMA was clear-cut, questions remained about what exactly the Proposition 8 ruling will mean on the ground.
There is likely to be more litigation over whether the district court ruling applies state-wide.
In the DOMA case, Justice Anthony Kennedy wrote for the majority that the federal law, as passed by Congress in 1996, violated the US Constitution's guarantee of equal protection.
"The federal statute is invalid, for no legitimate purpose overcomes the purpose and effect to disparage and to injure those whom the state, by its marriage laws, sought to protect in personhood and dignity," Justice Kennedy wrote.
Justice Kennedy, often the court's swing vote in close decisions, also said the law imposes "a stigma upon all who enter into same-sex marriages made lawful by the unquestioned authority of the states".
Chief Justice John Roberts and Justice Antonin Scalia both wrote dissenting opinions.
Justice Roberts himself wrote the Proposition 8 opinion, ruling along procedural lines with the court split in an unusual way.
Twelve of the 50 states and the District of Columbia recognise gay marriage; more than 30 states prohibit it, and others have laws somewhere in-between.
Section 3 of the Defense of Marriage Act limited the definition of marriage as between a man and a woman for the purposes of federal benefits.
By striking down Section 3, the court cleared the way to more than 1,100 federal benefits, rights and burdens linked to marriage status.
US President Barack Obama has applauded the rulings and directed the US Attorney General to review the federal laws for its implications.
Mr Obama said the decisions righted wrongs and the US is a better off country.