The ruling on the federal U.S. legislation known as DOMA gives spouses in same-sex unions a full array of tax, health and pension benefits.
The challenge to the legislation was spearheaded by 83-year-old Edith Windsor, a New Yorker, who married her longtime partner Thea Spyer six years ago in Canada, where same-sex marriage has been legal for almost a decade. The couple's marriage was recognized by New York state, but not by the federal government.
When Spyer died in 2009, the federal government cited DOMA to force Windsor, who's now ailing, to pay $363,000 in taxes on her late wife's estate — taxes that wouldn't have been levied against her if she'd been married to a man.
Windsor wasn't at the Supreme Court on Wednesday, but watched from her lawyer's apartment in New York, where she was reportedly jubilant upon word that DOMA had been struck down. The law had been in effect since 1996, when it was signed into law by a now-apologetic Bill Clinton.
"Children born today will grow up in a world without DOMA," a beaming Windsor told a New York news conference.
"And those children who are gay will be free to grow up and love and be married .… If I had to survive Thea, what a glorious way to do it. And she would be so pleased."
Also on Wednesday, the high court cleared the way for same-sex marriage in California by ruling that defenders of Proposition 8, a ban on same-sex marriage, had no constitutional standing. That means a lower court ruling in California that legalized same-sex marriage is again the law of the land.
The two historic rulings will likely transform the United States on same-sex marriage, an issue now widely considered a civil rights battle — and one that is dramatically winning the support of Americans.
U.S. President Barack Obama, the first commander-in-chief in American history to back same-sex marriage, praised the Supreme Court in a statement on Tuesday released after he personally called the plaintiffs involved in the two cases to congratulate them.
"This was discrimination enshrined in law," he said.
"It treated loving, committed gay and lesbian couples as a separate and lesser class of people. The Supreme Court has righted that wrong, and our country is better off for it. We are a people who declared that we are all created equal – and the love we commit to one another must be equal as well."
As many legal experts predicted, it was Justice Anthony Kennedy, a libertarian conservative on the panel, who broke partisan ranks on the nine-member panel and voted in favour of striking down DOMA. Kennedy had already written two judgments for the court that upheld the rights of gays.
"DOMA instructs all federal officials, and indeed all persons with whom same-sex couples interact, including their own children, that their marriage is less worthy than the marriages of others," Kennedy wrote in his decision.
"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."
The latest polls suggest the majority of Americans now support same-sex marriage, compared with just 13 per cent 25 years ago.
It's not just a generation gap that explains the profound shift, pollsters are discovering — even some older Americans are changing their minds about gay marriage, as are citizens in rural areas, from religious backgrounds and in traditionally conservative jurisdictions.
Amid that backdrop, the Supreme Court heard arguments in March against both laws. The arguments, made before the panel of five Republican appointees and four Democrats, were heard even as some high-profile Republicans, long consumed with winning over the social conservatives of their base, expressed support for same-sex marriage.
Ohio Sen. Rob Portman reversed his stance after his college-age son revealed he was gay. Jon Huntsman, a Mormon and a Republican presidential candidate in 2012, has also backed same-sex marriage and urged his fellow Republicans to do the same.
Even Karl Rove, the powerful Republican strategist who famously brought millions of Christian evangelicals into the party fold a decade ago, says he wouldn't be surprised if the 2016 Republican presidential candidate — whoever that may be — backs same-sex marriage.
Obama has helped embolden fellow politicians on same-sex matrimony after he reversed his own stance on the issue last year. The White House had urged the high court to rule in favour of same-sex rights.
Hillary Clinton, eyeing a run for president in 2016, has also expressed her support.
Speaker John Boehner, meanwhile, said he was “disappointed” in the Supreme Court’s DOMA ruling and suggested states may rule differently in the future. Same-sex marriage is currently legal in 13 U.S. states.
"While I am obviously disappointed in the ruling, it is always critical that we protect our system of checks and balances," Boehner said in a statement. "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."
The religious right vowed a battle.
In a series of Tweets, the American Family Association's Bryan Fischer wrote: "Sodomy-based marriage is an egregious violation of the 'Laws of Nature and Nature's God.' May God have mercy on us."
He added: "In our battle to defend marriage as God has defined it, we will never give in. We will never, never, never, never give in."
Mike Huckabee, a onetime Republican presidential candidate, also took to Twitter to express his dismay.
"My thoughts on the SCOTUS ruling that determined that same sex marriage is okay: 'Jesus wept.'"