Democrats are centering their campaign to retake Congress and defeat President Trump’s Supreme Court pick on a staunch defense of the Affordable Care Act, the landmark health-care law that Republicans used to wipe away their majorities in the past two midterm elections.

Democratic candidates and groups are trumpeting support for popular elements of President Barack Obama’s signature law and attacking Republicans for trying to rescind them in last year’s failed repeal-and-replace effort. Liberal activists also are seeking to convince centrist senators that confirmation of Trump’s new Supreme Court nominee, U.S. Appeals Court Judge Brett M. Kavanaugh, would increase the odds that courts would dismantle the law known as Obamacare.

The strategy is a significant turnabout from the previous two midterm elections when many Democrats avoided defending the Affordable Care Act, and illustrates the extent to which the law has taken root as millions of Americans have come to depend on it. Republicans, who relentlessly attacked Democrats for supporting the ACA in 2010 and 2014, are now largely steering their campaigns toward different topics.

“When they were running against Obamacare, they were really just running against Obama. And they were causing people to fear the unknown. And that was effective,” Sen. Brian Schatz (D-Hawaii) said in an interview. “Now, it’s no longer theoretical, rhetorical or even political for most of these folks. They don’t want to be harmed.”

Eight years after Obama signed the far-reaching measure, igniting a wave of fury on the right and a duck-and-cover strategy on the left, the politics of health care have undergone a stark transformation that is evident in both parties, from the desert towns of Nevada to the Florida seaside.

“In the past, voters had opposition to anything you called Obamacare — it hardly mattered what the explanation was,” said Steven Law, the president of American Crossroads, a conservative group. “I sat in focus groups where you had lower-income independent women who believed doctor office wait times were caused by Obamacare. I don’t think people make that intuitive connection that they did before.”

Democrats on the front lines of the battle for Congress are talking more openly than ever about protecting the health-care law. They frequently contrast their positions with the GOP push in 2017 to repeal and replace the ACA, an effort that collapsed in the Senate after three Republicans banded together with Democrats to defeat it.

On Saturday, Rep. Jacky Rosen, the Democratic Senate nominee in the battleground of Nevada, started airing a TV ad attacking Republican Sen. Dean Heller for supporting the repeal-and-replace plan under pressure from Trump.

In Florida, another pivotal state in the fight for Senate control, a leading Democratic super PAC recently launched an ad featuring an emergency room doctor in scrubs declaring that Sen. Bill Nelson (D) “took on the insurance companies, forcing them to cover people with preexisting conditions.” The ad does not name the Affordable Care Act, but it cites Nelson’s votes for the law and against repeal in small lettering.

In Arkansas’s 2nd District, which Trump won by more than 10 points, Democrat Clarke Tucker released an ad in April citing his battle with cancer and declaring that “health care is a right.” He pledged “to stand up to anyone who tries to take your health insurance.” He is now the nominee against Rep. French Hill (R), who supported the GOP overhaul.

In two special election wins on conservative terrain in Alabama and Pennsylvania, the Democratic candidates rejected GOP repeal efforts even as they adopted more conservative positions on other issues.

“We’ve learned a lesson,” said Richard J. Durbin (Ill.), the second-ranking Democratic senator. “The American people are tuned in to the failure of the Republicans to come up with an alternative to Obamacare.”

Since spring 2017, Americans have been more favorable than unfavorable toward the ACA, according to Kaiser Family Foundation polling, which showed the law reaching peak popularity in February. In the past, opinions had been much more unfavorable.

Other factors also have made campaigning on health care more complicated for Republicans. The failed repeal effort has left a bitter taste for conservative voters who yearned for them make good on their longtime promise to shred the law.

At the same time, huge insurance premium spikes are expected at a moment when Republicans control the White House and Congress, driven in part by Trump administration decisions.

“For years, Obamacare was something to fire up our base. Now ‘protect Obamacare’ is a rallying cry for Democratic enthusiasm,” said Chris Wilson, a Republican pollster working on several Senate races.

In 2010, a backlash against the law helped Republicans gain 63 House seats, more than enough to win the majority. Exit polling that year showed that 48 percent of voters — a plurality — said Congress should repeal the health-care law.

Four years later, the GOP pummeled Democrats with ads attacking them for supporting the legislation. The troubled rollout of the ACA’s online insurance marketplace forced some Democrats to run ads distancing themselves from the debacle.

Republicans won back control of the Senate that fall. After the election, now-Senate Minority Leader Charles E. Schumer (D-N.Y.) scolded his party for prioritizing health-care legislation in the first place. “We should have done it. We just shouldn’t have done it first,” he said.

This year, Republican candidates and groups are focused on other subjects. Law, whose group attacked Democrats over health care in the past, predicted that the Affordable Care Act probably “wouldn’t be the dominant issue in the fall,” and would be eclipsed by taxes, immigration and the Supreme Court. Republican Senate candidates in states Trump won are campaigning on those issues now.

Control of the Senate will depend heavily on states such as North Dakota, which Trump carried by a wide margin and where a Democrat, Sen. Heidi Heitkamp, faces reelection. Under the ACA, North Dakota expanded Medicaid, the insurance program for disabled and low-income Americans that plays an influential role in rural areas. So did West Virginia, another rural state, where Democratic Sen. Joe Manchin III is in a tough reelection fight.

“I think that’s a clear point of delineation,” Heitkamp said. “We’re trying to make health-care and premiums more affordable and less expensive, and everything that the administration and that the Republicans are doing is to drive the cost up.”

Heitkamp and Manchin have not said whether they will vote for Kavanaugh. But they are facing an aggressive campaign from fellow Democrats who are trying to use the issue of health care to pressure them to vote no, rather than focusing on abortion rights as they are doing in other states.

“This isn’t rocket science,” said Brian Fallon, who heads the group Demand Justice. “In these red states, where pro-life sentiment runs a little bit higher and you have pro-life senators, the plan has always been to talk about the risk that Brett Kavanaugh would pose on ACA.”

Two days after Trump announced Kavanaugh as his nominee, a group of Democratic senators led by Schumer held a news conference on Capitol Hill with a big red sign with a long list of medical conditions under the words, “The Supreme Court could take away your health care if you have a history of . . . ”

But many health-care experts have concluded that Kavanaugh would be more likely to help decide issues much narrower than the overall survival of the ACA. And Republicans have accused Democrats of spreading falsehoods. “That’s just fearmongering,” said Sen. Mike Rounds (R-S.D.).

At least one Democratic Senate candidate is also skeptical of the focus on the health-care law.

“If you go down the road of voting or not voting for a justice who could be there for 35 years based on how you think they’re going to vote on some issue which is up next spring or something, I just think you’re making a fundamental mistake,” former Tennessee governor Phil Bredesen, the likely Democratic Senate nominee in the state, said in an interview.

“This kind of reflexive, ‘We’re going to fight him tooth-and-nail right now knowing what we know now’ — I just think it’s the wrong” approach, he said, taking issue with the posture of Schumer and other party leaders.

Heitkamp, Manchin and Sen. Joe Donnelly (D-Ind.) each voted to confirm Neil M. Gorsuch as a Supreme Court justice last year. Republicans are hoping they can count on their support for Kavanaugh, given the pressures to align with Trump in their states.

A battle is also underway for the votes of Republican Sens. Susan Collins (Maine) and Lisa Murkowski (Alaska), who favor abortion rights and opposed the ACA repeal bill last year.

If all Democrats band together against Kavanaugh, they will still need at least one Republican to join them to defeat him under the Senate’s current 51-49 split and with Sen. John McCain (R-Ariz.) at home undergoing treatment for brain cancer.

Beyond the court fight, there are other areas in which Democrats disagree about health care. An increasingly powerful bloc of liberals who favor a single-payer health-care system has worried some Democrats who are not ready to embrace the idea, including strategists who fear alienating moderate voters.

Talking about the ACA remains a delicate task, particularly in conservative areas where the former president is unpopular. Many Democrats, including Heitkamp, continue to say the law must be improved and, like the pro-Nelson ad in Florida, avoid referring to it in association with Obama.

Still, broad agreement exists in the party about the importance of health care and the urgency to elevate the issue in November.

“We should be talking about health care every day from now until the election,” Schatz said. “We are running on protecting people, not a statute.”

Erica Werner in Piperton, Tenn., and Emily Guskin contributed to this report.