Washington CNN  — 

In a landmark opinion, a divided Supreme Court on Friday ruled that same-sex couples can marry nationwide, establishing a new civil right and handing gay rights advocates a historic victory.

In the 5-4 ruling, Justice Anthony Kennedy wrote for the majority with the four liberal justices. Each of the four conservative justices wrote their own dissent.

Nearly 46 years to the day after a riot at New York’s Stonewall Inn ushered in the modern gay rights movement, the decision could settle one of the major civil rights fights of this era. The language of Kennedy’s opinion spoke eloquently of the most fundamental values of family, love and liberty.

READ: The Supreme Court’s full decision

“No union is more profound than marriage, for it embodies the highest ideals of love, fidelity, devotion, sacrifice and family,” Kennedy wrote. “In forming a marital union, two people become something greater than they once were.”

‘Equal dignity in the eyes of the law’

“Their hope,” Kennedy wrote, “is not to be condemned to live in loneliness, excluded from one of civilization’s oldest institutions. They ask for equal dignity in the eyes of the law. The Constitution grants them that right.”

Kennedy has written the opinion in significant gay rights cases and when he uttered the key sentence that same-sex couples should be able to exercise the right to marry in all states, people in the Court’s public gallery broke into smiles and some wiped tears from their eyes.

Reaction: People soak up history from coast to coast

In a dissent, Justice Antonin Scalia blasted the Court’s “threat to American democracy.”

“The substance of today’s decree is not of immense personal importance to me,” he wrote. “But what really astounds is the hubris reflected in today’s judicial Putsch.”

Chief Justice John Roberts wrote that the decision had “nothing to do with the Constitution.”

READ: The best lines from Scalia’s marriage dissent and Kennedy’s decision

“If you are among the many Americans—of whatever sexual orientation—who favor expanding same-sex marriage, by all means celebrate today’s decision. Celebrate the achievement of a desired goal,” he wrote. “Celebrate the opportunity for a new expression of commitment to a partner. Celebrate the availability of new benefits. But do not celebrate the Constitution. It had nothing to do with it.”

The U.S. is now the 21st country to legalize same-sex marriage nationwide, including territories. Married same-sex couples will now enjoy the same legal rights and benefits as married heterosexual couples nationwide and will be recognized on official documents such as birth and death certificates.

Hundreds of same-sex marriage supporters flooded the plaza and sidewalk in front of the Court to celebrate the ruling, proudly waving rainbow flags and banners with the Human Rights Campaign’s equal sign, which have come to represent the gay rights movement. In an emotional moment, the supporters sang the National Anthem, clapping wildly after singing that the U.S. is “the land of the free.”

WATCH: Obama calls gay marriage case plaintiff Jim Obergefell

After the ruling, President Barack Obama called Jim Obergefell, the lead plaintiff in the case, while he and his supporters celebrated the ruling outside the court.

Obama: ‘Congratulations’

“I just wanted to say congratulations,” Obama said as CNN broadcast his warm words to Obergefell over speakerphone. He added: “Your leadership on this has changed the country.”

Obama calls same-sex marriage plaintiff after victory
Obama calls same-sex marriage plaintiff after victory
01:58 - Source: CNN

Speaking at the White House later in the morning, Obama said “Americans should be very proud,” because small acts of courage “slowly made an entire country realize that love is love.”

By the numbers: Same-sex marriage

The decision affirmed growing public support in the U.S. for gay marriage, with about two-thirds of Americans now in favor. And it comes as gay rights groups have seen gay marriage bans fall rapidly in recent years, with the number of states allowing gay marriage swelling most recently to 37 – that is, until this ruling.

There were two questions before the Court, the first asked whether states could ban same sex marriage, the second asked whether states had to recognize lawful marriages performed out of state.

The relevant cases were argued earlier this year. Attorney John Bursch, serving as Michigan’s Special Assistant Attorney General, defended four states’ bans on gay marriage before the Court, arguing that the case was not about how to define marriage, but rather about who gets to decide the question.

The case came before the Supreme Court after several lower courts overturned state bans on gay marriage. A federal appeals court had previously ruled in favor of the state bans, with Judge Jeffrey Sutton of the Sixth Circuit U.S. Court of Appeals writing a majority opinion in line with the rationale that the issue should be decided through the political process, not the courts.

14 couples

Fourteen couples and two widowers challenged the bans. Attorneys Mary Bonauto and Doug Hallward-Driemeier presented their case before the Court, arguing that the freedom to marry is a fundamental right for all people and should not be left to popular vote.

Three years after Obama first voiced his support for gay couples’ right to marry, his administration supported the same sex couples at the Supreme Court.

“Gay and lesbian people are equal,” Solicitor General Donald B. Verrilli Jr. told the justices at the oral arguments earlier this year. “It is simply untenable – untenable – to suggest that they can be denied the right of equal participation in an institution of marriage, or that they can be required to wait until the majority decides that it is ready to treat gay and lesbian people as equals.

MAP: Where same-sex marriage is recognized in the U.S.

Obergefell, the lead plaintiff in the case, married his spouse John Arthur in 2013 months before Arthur died.

The couple, who lived in Ohio, had to travel to Maryland aboard a medical jet to get married when Arthur became gravely ill. And when Arthur died, Obergefell began to fight to be recognized as Arthur’s spouse on his death certificate.

The plaintiffs from Michigan are April DeBoer and Jayne Rowse, two Detroit-area nurses who are also foster parents. They took to the courts after they took in four special-needs newborns who were either abandoned or surrendered at birth, but could not jointly adopt the children because Michigan’s adoption code requires that couples be married to adopt.

Milestones for LGBT rights

Sgt. Ijpe Dekoe and Thomas Kostura became plaintiffs in the gay marriage case after they moved to Tennessee from New York.

The pair had married in New York in 2011, but Dekoe’s position in the Army took the couple to Tennessee, which banned gay marriage and refused to recognize gay marriages performed in other states.

2016

Republicans seeking the White House struggled to find their footing after the ruling.

Candidates running closer to the center, including former Florida Gov. Jeb Bush and South Carolina Sen. Lindsey Graham, issued tightly-parsed language urging their colleagues to focus on protecting “religious freedom”. And Ohio Gov. John Kasich urged Republicans to respect the ruling and ditch the matter altogether.

“In a country as diverse as ours, good people who have opposing views should be able to live side by side. It is now crucial that as a country we protect religious freedom and the right of conscience and also not discriminate,” Bush said in his statement.

READ: Roberts vs. Scalia in Obamacare bout

But conservative firebrands, including Louisiana Gov. Bobby Jindal and former Arkansas Gov. Mike Huckabee, said that conservatives must stand and fight by seeking a constitutional amendment banning gay marriage.

“I will not acquiesce to an imperial court any more than our founders acquiesced to an imperial British monarch. We must resist and reject judicial tyranny, not retreat,” Huckabee said in a statement.

Democrats had no problem reacting, jumping fast on Twitter to express their universal elation.

Former Secretary of State Hillary Clinton said she was “proud” of the ruling and former Maryland Gov. Martin O’Malley tweeted a photo of the family at the center of his state’s efforts to legalize gay marriage.