The Supreme Court ruled, 5 to 4, that same-sex marriage bans are unconstitutional. Here’s what you need to know. (Gillian Brockell/The Washington Post)

The U.S. Supreme Court’s decision Friday legalizing same-sex marriage across the country has confronted the Republican Party with a choice: to rally the base by continuing to fight, or take the loss and move on.

Gay marriage is an issue for which public support has grown with a speed unlike that seen on any other social question in modern history.

Opposition remains strong, however, among religious and social conservatives. That segment of voters is crucial to the GOP coalition and a key to victory in some of the early-contest states, including Iowa, South Carolina and much of the rest of the South.

The dilemma presented by the same-sex marriage ruling expressed itself almost immediately in the reactions from the party’s enormous field of declared and presumed 2016 presidential candidates. They ranged from defiant to pragmatic, apocalyptic to philosophical.

In each, there was a glimpse of how the candidates have mapped out their path to victory.

“I will not acquiesce to an imperial court any more than our Founders acquiesced to an imperial British monarch,” former Arkansas governor Mike Huckabee said. “We must resist and reject judicial tyranny, not retreat.”

Huckabee’s comments reflected his background as a Southern Baptist minister, but also the fact that he is basing his campaign strategy on winning the Iowa caucuses, as he did in 2008, on the strength of his dominance among evangelical voters.

In 2016, however, Huckabee can expect a strong challenge for that segment of the electorate. Among them is Sen. Ted Cruz (Tex.), who told a rally in northwestern Iowa on Friday that the court decision was “the very definition of lawlessness.”

Louisiana Gov. Bobby Jindal, an underdog who this week became the 13th formally declared GOP presidential candidate, predicted that the decision “will pave the way for an all-out assault against the religious freedom rights of Christians who disagree.”

Other GOP candidates, while criticizing the ruling, expressed acceptance and sought to refocus on other issues that were raised by the ruling.

“While I disagree with this decision, we live in a republic and must abide by the law,” said Sen. Marco Rubio (Fla.). “As we look ahead, it must be a priority of the next president to nominate judges and justices committed to applying the Constitution as written and originally understood.”

Former Florida governor Jeb Bush struck a similar tone: “I believe the Supreme Court should have allowed the states to make this decision. I also believe that we should love our neighbor and respect others, including those making lifetime commitments. In a country as diverse as ours, good people who have opposing views should be able to live side by side.”

President Obama lauded the Supreme Court ruling in favor of same-sex marriage at the White House on June 26, 2015. Here are key moments from Obama’s speech. (AP)

Such measured responses could play better in the first GOP primary in New Hampshire, as well as in the general election.

Opinion polls show that a majority of Americans — and a significant percentage of Republicans — now support same-sex marriage.

It represents a sharp political swing from the politics of only a decade ago. In the 2004 election, gay marriage was on the ballot in 11 states — and in all of them, voters rejected it. Further, the issue helped drive Republican voter turnout to return George W. Bush to the White House.

There are still strong differences in support for same-sex marriage in various parts of the country. The Pew Research Center found last year that in 18 states, less than half the public favored same-sex marriage. Pew also has reported that opposition was at 50 percent or higher among seniors, African Americans, white evangelicals, weekly churchgoers, and Republicans who identify themselves as conservative.

Controversial court decisions have sometimes served as a valuable political organizing tool for the right.

“The decision by this Supreme Court to redefine marriage contrary to global and historical understandings of the word no more settles the national debate on marriage than the court’s Roe v. Wade decision over 40 years ago settled the national debate on abortion,” said Tim Head, executive director of the Faith and Freedom Coalition, an organization that mobilizes evangelicals in politics.

One difference, however, is that overall public opinion on abortion has remained relatively stable since that 1973 decision, with most people believing that the procedure should remain legal in some circumstances. So opponents have focused their efforts on chipping away at abortion availability, with such measures as parental-consent laws and restrictions on facilities that provide the procedure.

There are almost no practical choices for unraveling what the court has done on same-sex marriage.

Wisconsin Gov. Scott Walker (R), who is likely to announce his candidacy in mid-July, called the ruling “a grave mistake” and endorsed a constitutional amendment allowing states to define marriage.

But one of his 2016 rivals, Sen. Lindsey O. Graham (R-S.C.), said that “given the quickly changing tide of public opinion on this issue,” there is virtually no chance that an amendment could win a two-thirds majority in Congress and ratification by three-quarters of the states.

Still, although gay marriage will almost certainly remain legal, there will be other battles around it. Chief Justice John G. Roberts Jr. noted in his dissenting opinion that the court’s decision did not settle such questions as whether a religious college might provide married-student housing only to heterosexual couples, or a church-run adoption agency might decline to place children with same-sex parents.

The court decision comes at a moment when battle cries to protect “religious freedom” have become reliable applause lines at GOP gatherings. Conservatives see government encroachments not only on traditional marriage, but also in areas such as health care, where the Affordable Care Act requires insurance to cover contraception.

The GOP reaction contrasted sharply with the jubilant response of several Democratic presidential candidates, who praised the decision and cast it as reflective of an evolving, more tolerant United States.

As recently as the 2008 presidential election, both of the leading Democratic contenders — Barack Obama and Hillary Rodham Clinton — were publicly opposed to gay marriage. But they and most other Democrats have since embraced such unions as a constitutional right.

Clinton, whose Twitter page on Friday featured the word “HISTORY” in rainbow colors, took a dig at Republicans who oppose the ruling.

“As love and joy flood our streets today, it is hard to imagine how anyone could deny the full protection of our laws to any of our fellow Americans — but there are those who would,” Clinton said in a statement. “So while we celebrate the progress won today, we must stand firm in our conviction to keep moving forward.”

Scott Clement contributed to this report.