The US Supreme Court has handed two major victories to advocates of gay marriage, ruling that same-sex couples should get the same federal benefits as heterosexual couples and clearing the way for the resumption of same-sex marriages in California, the most populous US state.
The rulings, both by 5-4 margins, do not mean that gay marriage will be permitted throughout the United States; most states still ban it.
But they build on the momentum of the gay rights movement, with its broad shift in public attitudes, a dozen states adopting gay marriage and a US president, Barack Obama, who has advocated for gay rights.
In one case, the court invalidated provisions of the federal Defense of Marriage Act that has prevented married gay couples from receiving a range of tax, health and retirement benefits that are generally available to married people.
The second case was a technical legal ruling that left in place a lower court's ruling striking own California's ban on gay marriage.
It found that the defenders of the ban did not have the right to appeal the decision.
The ruling probably will allow state officials to order the resumption of same-sex unions in about a month.
Obama praised the court's ruling on the federal marriage act, which he said ''was discrimination enshrined in law.''
Obama decided in 2011 to stop defending the 1996 law, concluding that it was legally indefensible.
''It treated loving, committed gay couples and lesbians as a separate and lesser class of people,'' Obama said in a statement.
''The Supreme Court has righted that wrong and our country is better off for it.''
Obama telephoned his congratulations to the plaintiffs in the California case from Air Force One en route to Africa.
US Defence Secretary Chuck Hagel said the Pentagon would begin the process to extend benefits to the same-sex spouses of military members as soon as possible.
Defence officials estimate there are 18,000 same-sex couples in the active duty, National Guard and Reserves.
It's unclear how many of those are married.
The repeal of the ban on openly gay military service took effect in September 2011.
Outside the Supreme Court, supporters of same-sex marriage burst into cheers and some wept openly upon hearing the decision.
Chants of ''Thank you'' and ''USA'' came as the plaintiffs in the cases descended the marbled steps.
The outcome is clear for people who were married and live in states that allow same-sex marriage. They now are eligible for federal benefits.
The picture is more complicated for same-sex couples who travelled to another state to get married, or who have moved from a gay marriage state since being wed.
Their eligibility depends on the benefits they are seeking.
For instance, immigration law focuses on where people were married, not where they live.
But eligibility for government pension benefits basically depends on where a couple is living when a spouse dies.
The rulings came 10 years to the day after the court's Lawrence v. Texas decision that struck down state bans on gay sex.
In his dissent at the time, Justice Antonin Scalia predicted the ruling would lead to same-sex marriage.
Same-sex marriage now has been adopted by 12 states and the Washington district.
Another 18,000 couples were married in California during a brief period when same-sex unions were legal there.