WASHINGTON — Same-sex couples won the right to marry nationwide Friday as a divided Supreme Court handed a crowning victory to the gay rights movement, setting off a jubilant cascade of long-delayed weddings in states where they had been forbidden.

“No longer may this liberty be denied,” said Justice Anthony Kennedy.

The vote was narrow — 5-4 — but Kennedy’s majority opinion was clear and firm: “The court now holds that same-sex couples may exercise the fundamental right to marry.”

The ruling will put an end to same-sex marriage bans in the 14 states that still maintain them, and provide an exclamation point for breathtaking changes in the nation’s social norms in recent years.

The decision doesn’t change what’s been happening in North Carolina, since federal judges last October overturned the state’s constitutional amendment that limited marriage to a man and a woman. Just over one-third of the states permit gay marriages.

County officials have been presiding over gay marriages since Oct. 10. Legal challenges seeking to preserve the amendment’s validity — approved by 61 percent of voters in May 2012 — will be moot. But lawmakers may soon face a legal fight over a new law that allows some court workers to refuse to participate in gay marriages.

In praise of the decision, President Barack Obama called it “justice that arrives like a thunderbolt.”

Four of the court’s justices weren’t cheering. The dissenters accused their colleagues of usurping power that belongs to the states and to voters, and short-circuiting a national debate about same-sex marriage.

“This court is not a legislature. Whether same-sex marriage is a good idea should be of no concern to us,” Chief Justice John Roberts wrote in dissent. Roberts read a summary of his dissent from the bench, the first time he has done so in nearly 10 years as chief justice.

“If you are among the many Americans — of whatever sexual orientation — who favor expanding same-sex marriage, by all means celebrate today’s decision,” Roberts said. “But do not celebrate the Constitution. It had nothing to do with it.”

Justice Antonin Scalia said he was not concerned so much about same-sex marriage as “this court’s threat to American democracy.” He termed the decision a “judicial putsch.” Justices Samuel Alito and Clarence Thomas also dissented.

The majority ruling “will no more settle the issue of gay marriage than Roe v. Wade settled the issue of abortion,” said Tami Fitzgerald with the North Carolina Values Coalition, referring to the 1973 Supreme Court case. She said there must be guarantees that “North Carolinians whose religious beliefs are violated by this decision will have the continuing freedom to act on their beliefs.”

Kennedy said nothing in the court’s ruling would force religions to condone, much less perform, weddings to which they object. And he said the couples seeking the right to marry should not have to wait for the political branches of government to act.

The 14th Amendment to the Constitution requires states to allow same-sex couples to marry on the same basis as heterosexuals, he said.

“The dynamic of our constitutional system is that individuals need not await legislative action before asserting a fundamental right. The nation’s courts are open to injured individuals who come to them to vindicate their own direct, personal stake in our basic charter,” Kennedy wrote in his fourth major opinion in support of gay rights since 1996. It came on the anniversary of two of those earlier decisions.

As he read his opinion, spectators in the courtroom wiped away tears. One of those in the audience was James Obergefell, the lead plaintiff in the Supreme Court fight. Outside, Obergefell held up a photo of his late spouse, John Arthur, and said the ruling establishes that “our love is equal.” He added, “This is for you, John.”

Obama placed a congratulatory phone call to Obergefell, which he took amid a throng of reporters outside the courthouse. Speaking a few minutes later at the White House, Obama praised the decision as an affirmation of the principle that “all Americans are created equal.”

The ruling will not take effect immediately because the court gives the losing side roughly three weeks to ask for reconsideration. But county clerks in Alabama, Georgia, Mississippi, Ohio, North Dakota, South Dakota, Tennessee and Texas began issuing licenses to same-sex couples within hours of the decision.

Gay rights groups and Democrats in the North Carolina legislature already are looking at challenging in court a new state law allowing magistrates and some register of deeds workers to refuse to participate in gay marriage duties based on their religious objections. They say the law is discriminatory and was enacted illegally.

The Republican-led General Assembly on June 11 overrode Gov. Pat McCrory’s veto of the bill. McCrory said no public official voluntarily taking an oath should be exempt from upholding their constitutional duties. Court employees who cite the objection will be unable to officiate at any marriage — gay and traditional.

There are an estimated 390,000 married same-sex couples in the United States, according to UCLA’s Williams Institute, which tracks the demographics of gay and lesbian Americans. Another 70,000 couples living in states that do not currently permit them to wed would get married in the next three years, the institute says. Roughly 1 million same-sex couples, married and unmarried, live together in the United States, the institute says.