An angry Ted Cruz (R-Tex.) took to the Senate floor to express his disapproval of the court’s decision to uphold a key provision of Obamacare, calling the justices "robed Houdinis." (SenTedCruz/YouTube)

Even as Republicans rose in a chorus of outrage Thursday over the Supreme Court’s refusal to gut the Affordable Care Act, party leaders were privately relieved.

Republicans were spared the challenge of having to come up with a solution for the 6.4 million Americans — most of them in conservative states — who might have found their health insurance unaffordable had the court gone the other way.

And as it moves into a presidential election season, the party can continue to galvanize the conservative base by railing against both the law and the high court.

“Every GOP candidate for the Republican nomination should know that this decision makes the 2016 election a referendum on the full repeal of Obamacare,” said Sen. Ted Cruz (Tex.), one of the 13 Republicans who have declared they are running.

At the same time, the court’s second ruling in favor of the five-year-old law has increased the pressure on Republicans to tell the country how they would fix the health-care system.

“A Republican nominee for president will have to have a plan to replace the law,” said former Republican National Committee chairman Ed Gillespie, who in his failed Senate campaign in Virginia last year was virtually the only nationally prominent member of his party to come up with one.

David Winston, a pollster who advises the GOP congressional leadership, said, “Ultimately, the challenge for Republicans is not just how to deal with this law, but where’s the direction? Where are the alternatives?”

Republicans do have some ideas. They support, for example, the law’s provision preventing insurance companies from denying coverage to people with preexisting conditions and requiring them to allow parents to carry their young adult offspring on their policies. Most also argue for allowing insurers to sell policies across state lines.

Winston also pointed to a bipartisan proposal, advanced by House Energy and Commerce Committee Chairman Fred Upton (R-Mich.) and ranking committee Democrat Diana DeGette (D-Colo.), that aims to accelerate the pace of medical breakthroughs.

But none of the GOP proposals would go as far as the Affordable Care Act has in guaranteeing coverage, and many health experts say that a piecemeal approach would send health-care costs soaring.

One thing that is certain: The issue will not go away.

“ObamaCare is fundamentally broken, increasing health-care costs for millions of Americans,” House Speaker John A. Boehner (R-Ohio) said in a statement issued by his office. “Today’s ruling doesn’t change that fact.”

With its decision to uphold a key Obamacare provision, the Supreme Court cemented President Obama's legacy, says The Post's Chris Cillizza, and in a way let Republican presidential candidates off the hook. (Tom LeGro/The Washington Post)

Indeed, the initial round of rhetoric after the court decision suggested that the ruling had further inflamed the right and given the growing field of Republican presidential contenders a new battle cry.

“Our Founding Fathers didn’t create a ‘do-over’ provision in our Constitution that allows unelected, Supreme Court justices the power to circumvent Congress and rewrite bad laws,” former Arkansas governor Mike Huckabee said in a statement while campaigning in southern Iowa.

“The decision turns both the rule of law and common sense on its head,” Sen. Rand Paul (R-Ky.) said in a statement. “As president, I would make it my mission to repeal it, and propose real solutions to our health care system.”

Democrats also saw in the court’s decision an opportunity to change the political dynamic around the issue.

Former secretary of state Hillary Rodham Clinton, the odds-on favorite for the Democratic nomination, issued a statement noting Republicans in Congress have “voted more than 50 times to repeal or dismantle the law, roll back coverage for millions of Americans, and let insurers write their own rules again — all without proposing any viable alternatives.”

“Now that the Supreme Court has once again re-affirmed the ACA as the law of the land,” she added, “it’s time for the Republican attacks to end. It’s time to move on.”

The justices, in a surprisingly strong 6-to-3 vote, ruled that government subsidies for health insurance should remain available not only in 16 states that have set up their own insurance marketplaces but also in the 34 states — most of them dominated by Republicans — that have refused to do so, relying on the federal government exchange instead.

That might sound like a technical issue, resolving ambiguous language in the bill that President Obama signed into law in 2010. But the practical effect of taking government assistance from people who bought their coverage on the federal ­exchanges could have made the entire law unworkable because so many consumers would have found their new insurance policies unaffordable, many health-care experts said.

Republicans would have been in a difficult spot if the court had struck down federal subsidies in the majority of states.

The decision was “a bad legal outcome but a good political outcome” for Republicans, Gillespie said.

“Today Democrats, and my guess is Republicans, are breathing one gigantic sigh of relief,” said Sen. Charles E. Schumer (D-N.Y.).

The fact that Americans hold conflicted views of the law and the choice that was before the court demonstrates how treacherous the politics of health care may be for Republicans going forward.

In a May Washington Post-ABC News poll, only 39 percent of respondents said they approve of the law, while 54 percent said they opposed it. But when asked whether the court should take away subsidies in states that rely on the federal exchanges, 55 percent said the justices should not; only 38 percent said they should.

Rick Wilson, a Florida-based GOP strategist, said he was “relieved by the decision,” but he acknowledged that there could still be problems ahead.

“What I don’t want is a political environment where, for the next year, we’re in a ditch with people asking, ‘What’s your exact health-care plan?’ and then when we present one it gets torn apart,” Wilson said. “Anyone who thinks that’s a great political frame to put yourself in for 2016 hasn’t ever done an election.”

Former Michigan governor John Engler, a Republican who heads the Business Roundtable, said that pressure will remain to fix elements of the law that are opposed by many in both parties, including the tax it would impose on high-cost “Cadillac” health policies and its tax on medical devices.

He said of the court decision: “What this means is that probably major changes in the Affordable Care Act will be debated in the 2016 election.”

Ed O’Keefe contributed to this report.