WASHINGTON — Contempt for the Affordable Care Act — Obamacare — was so central to Sen. Joni Ernst’s 2014 election campaign that the Iowa Republican, in a TV ad promising she’d “unload” on the law, pulled out a handgun and fired repeatedly. “Give me a shot,” she asked voters.

Six years later, the first-term senator is battling for reelection, and she’s holstered her gun.

Ernst is not alone. Earlier this month, she joined fellow Republican Sens. Cory Gardner of Colorado and Dan Sullivan of Alaska — two other would-be assassins of the 10-year-old healthcare law who are now fighting for their political survival — in breaking with their party to support Obamacare on the Senate floor. They voted with Democrats on a measure opposing a Republican-backed case against the law that’s now before the Supreme Court.

As that vote showed, endangered Republicans are frantically trying to pivot away from the “repeal Obamacare” slogans that served them well for much of the last decade. Those are now a liability amid a jump in public support for the healthcare law.

Candidates also are playing down the long-standing legal challenge initiated by a coalition of Republican-led states that’s reached the Supreme Court. And from President Trump on down, they claim to be guardians of Obamacare’s most popular provision — a guarantee of insurance coverage for people with preexisting conditions — though that mandate would fall with the rest of the law if the court’s conservative majority sides with Republicans.

“Republicans would much rather be talking about something else,” said Thomas P. Miller, a resident fellow at the American Enterprise Institute, a conservative think tank. “Public opinion on this has changed, and they are stuck with the consequences of saying for years they oppose the Affordable Care Act and not coming up with an alternative.”

For Democrats, the turnabout is fair play. After its passage in 2010, Obamacare was their albatross, contributing that year to the party’s loss of its House majority, and costing them politically for several more election cycles. As recently as 2016, former President Clinton called the law “the craziest thing in the world” and Democratic presidential nominee Hillary Clinton hedged on her support for it.

That began to change in the 2018 midterm election: Democrats recaptured a House majority, and voters’ healthcare concerns were a big factor. Now, in the closing weeks of a 2020 campaign upended by a worldwide pandemic, Democrats are making saving the Affordable Care Act their marquee issue.

Democrats up and down the ballot — from presidential nominee Joe Biden to candidates for Congress, state attorneys general and more — are embracing the healthcare law, and promising to expand its reach. In the Senate, they’ve been talking about it incessantly during this week’s hearings for Supreme Court nominee Amy Coney Barrett, hoping to benefit in the elections even if they can’t block her confirmation. Democratic senators brought poster-sized photos of constituents who would be hurt by repeal of Obamacare, and hammered on Trump’s promise that his nominee would help dismantle the law.

“If Republicans are litigating the merits of Obamacare in the final weeks of the election, that’s a losing proposition,” said Ken Spain, who was spokesman for the National Republican Congressional Committee in 2010. “Healthcare was an advantage for Republicans in 2010, but that has been radically reversed.”

Support for Obamacare has surged to record levels amid the pandemic, according to a Morning Consult poll in September that found 62% of registered voters favored the law. That was a sharp increase from 55% in March, explained almost entirely by rising support among Republicans and independents.

At least five endangered Senate Republicans who voted to repeal the Affordable Care Act are now running ads vowing they would never threaten the protections for people with preexisting conditions that are part of it.

Among them is Texas Sen. John Cornyn. His new ad promising “preexisting conditions is something we all agree should be covered” was quickly branded a “whopper” of a falsehood by fact-checkers at the Washington Post, who awarded it four “Pinocchios.”

In Colorado, Gardner’s promise to eviscerate Obamacare was prominent on his campaign website in 2014, but it’s disappeared for this cycle.

Even Republican Senate Majority Leader Mitch McConnell, a longtime champion of repeal, is backpedaling as he seeks reelection in Kentucky. During a debate this week, he tried to reassure voters the law would remain intact. “No one believes the Supreme Court is going to strike down the Affordable Care Act,” he said, ignoring his party’s early victories in lower courts.

Morning Consult also found that voters overwhelmingly trusted Biden over Trump — by a margin of 2 to 1 — to protect coverage for Americans with preexisting conditions, and that they were more likely to trust Democrats in Congress (49%) than Republicans (35%) to handle healthcare issues.

Rep. Don Bacon (R-Neb.), after voting in 2017 to repeal and replace key parts of Obamacare, said then that he had voted “Hell, yes.” Under attack now from his Democratic opponent, who supports “Medicare for all,” Bacon is trying to recast his past vote as one designed to protect Obamacare.

“I’m the one who wants to improve ACA,” he tweeted. “My opponent wants to trash all of ACA with a disastrous Medicare for all plan.”

In Utah, Republican House candidate Burgess Owens removed a call for repeal from his website, according to the Salt Lake Tribune. The website now says, “Obamacare no longer needs to be repealed, but changes are necessary in the current healthcare plan.”

Since his 2016 campaign, Trump has promised to unveil a new healthcare plan but never followed through. Late last month, he signed a toothless executive order proclaiming the government would protect people with preexisting conditions.

The upswing in support for the Affordable Care Act is just the latest twist in the political history of President Obama’s chief legislative accomplishment. It has been buffeted by legal challenges, reaching the Supreme Court twice before, and undermined by Trump administration policies. But its core features — the preexisting conditions coverage, a national marketplace for individuals to buy insurance, premium subsidies for the needy, expanded Medicaid in most states — remain in place.

“Everyone knows we can’t forfeit billions of dollars of our GDP to a right-wing flight of fancy,” said Sam Petsonk, a Democrat running for attorney general in West Virginia, where at least 160,000 people would lose their health insurance if Obamacare were repealed.

The GOP incumbent in that race, Patrick Morrisey, is a leader of the effort by conservative states to repeal the law, giving the Democrat a rich target. Democrats running for attorney general in other conservative states are also running on saving Obamacare, a once-unthinkable move.

“It is a centerpiece of my campaign,” Raph Graybill, the Democratic nominee for Montana attorney general. He emphasizes the lawsuit that Republican state attorneys general are pushing, and how their success would “allow insurance companies to take the medical struggles of people you love and turn them into an excuse to take away their care.”

Even in Montana, which Trump won by 20 percentage points in 2016, Republicans are paying a price for pushing repeal. Among them is Sen. Steve Daines, who won in a landslide in 2014 but now is in danger of losing his seat to his Democratic challenger, Gov. Steve Bullock.

Focus groups conducted by Democratic pollster Stan Greenberg in August found healthcare anxieties were substantially eroding support for Trump among his most reliable constituency: white working-class voters. Three-quarters of the participants voted for Trump in 2016. Only half planned to do so again. That shift, Greenberg wrote, was “profoundly shaped by what has happened in the healthcare crisis. …They think he is failing at the issue most important for them.”

Not all Republicans are backing away from their quest to kill Obamacare. Senate Judiciary Committee Chairman Lindsey Graham of South Carolina, who is in a surprisingly tough fight for reelection, lambasted the law and said he would rather give states more power over healthcare. He urged his Republican colleagues to join him in speaking up against Obamacare during the Barrett confirmation hearing.

“I hope my colleagues on this side of the aisle will not feel shy about telling my colleagues on the other side of the aisle why we think we have a better idea on healthcare,” Graham said.

None of them spoke.