On Tuesday, the Supreme Court took up the Proposition 8 case, the challenge to California’s ban on same-sex marriage. The Post’s Robert Barnes explains what you need to know from the hour of oral arguments. (JulieAnn McKellogg/The Washington Post)

If justices on the Supreme Court sounded cautious and tentative as they addressed the issue of same-sex marriage Tuesday, it’s little wonder. Like everyone else in public life, they are operating in the middle of a political whirlwind.

The political and legal systems are caught between past and future. Public opinion has shifted rapidly, and a majority of Americans now back legalizing same-sex marriage. Among those younger than 40, support is overwhelming. The question is when and in what form the future arrives.

There is little doubt that every Democrat who seeks the White House in 2016 will support same-sex marriage — a reality that wasn’t so obvious 18 months ago. The question for Republicans is whether any of their 2016 candidates will take a similar position.

There is no better reminder of how rapidly things have changed than to recall that President Obama declared his support for same-sex marriage just in May — and only after Vice President Biden got there first. Obama seemed as hesitant to change his position — it took him several years — as some of the justices sounded Tuesday about making sweeping rulings about the constitutionality of such unions.

Obama’s hesitancy was perhaps understandable. California’s Proposition 8, the ban on same-sex marriage that was the subject of Tuesday’s oral argument at the high court, was approved four years ago — and in a staunchly Democratic state. If that vote were held today, odds are that California voters would go the other way.

Politicians in both parties are scrambling to come to terms with the swift change in public opinion and how that fits with the views of their traditional constituencies. Today, it is considered perilous for any Democrat with national aspirations not to support same-sex marriage — which may explain why Hillary Rodham Clinton announced her support last week.

Clinton wasn’t alone. This week, a number of Democrats from purple or red states — Sens. Mark R. Warner of Virginia, Claire McCaskill of Missouri and Jon Tester of Montana, among others — announced their support. Many others are sure to follow, no matter what the Supreme Court does on Proposition 8.

Among Republicans, Sen. Rob Portman (Ohio) announced a change in position this month and now supports same-sex marriage. He was motivated because his son is gay. But Portman is in the minority among current or former elected officials in his party, in company with former vice president Dick Cheney and former Utah governor Jon Huntsman Jr.

Rank-and-file Republicans remain opposed to same-sex marriage. Overall, 59 percent of Republicans say they are against it, and nearly all feel strongly about that opposition, according to the latest Washington Post-ABC News poll. Yet Republicans are divided generationally. For the first time in a Post-ABC News poll, a majority of Republicans and Republican-leaning independents younger than 50 support legalizing same-sex marriage.

Republican leaders see the overall shifts in public opinion as clearly as do the Democrats and have responded accordingly. In 2004, Republicans used ballot initiatives barring same-sex marriage to spur turnout among their conservative voters. That strategy helped then-President George W. Bush win reelection. Many Republicans then favored a federal constitutional amendment barring same-sex marriage.

In 2012, Republican nominee Mitt Romney was mostly silent on the issue, other than to state his opposition. Democrats made it a consistent theme of their national convention, and Obama included it in his inaugural address in January.

GOP leaders know their position is no longer a winning one. They are now looking for a strategy to avoid making it a losing issue. Republican National Committee Chairman Reince Priebus told USA Today’s Susan Page this week that although the party does not need to change its official opposition to same-sex marriage, there is no reason “to act like Old Testament heretics” on the issue.

Priebus said Republicans should be welcoming to people with different views. “We’re not going to agree on every issue,” he said. “It doesn’t mean that we need to divide and subtract people from our party.” GOP strategist Karl Rove said he thinks it’s possible that one of the Republican candidates for president in 2016 will support same-sex marriage — although most of those talked about as potential candidates are opposed today.

The Supreme Court justices can see the contours of this debate — rapidly moving public opinion along with generational and geographic differences — and may choose not to deal directly with the California proposition. Absent a Supreme Court decision, the battle to legalize these unions will be waged state by state, with a patchwork that probably will divide red states from blue states.

Symbolically, however, the debate is in a different place. The rising segments of the population favor same-sex marriage — a reality that adds to pressures on the Republican Party as its leaders seek to put the GOP in a position to compete more effectively for the White House without offending the party’s conservative base.

Justice Anthony Kennedy observed Tuesday that the court was in “uncharted waters” as it weighed the constitutionality of same-sex marriage. But many politicians aren’t waiting for the court to act.