Republicans are facing a moment of reckoning on health care after a federal judge struck down the Affordable Care Act, imperiling the landmark law the GOP has struggled against for eight years.

During the midterm campaign, President Trump and Republican candidates vowed repeatedly to protect millions of Americans with preexisting medical conditions, as the law does, even as the administration embraced a legal challenge by 20 GOP-led states to the law commonly known as Obamacare.

That lawsuit led to Friday’s ruling by U.S. District Judge Reed O’Connor, who concluded the law is unconstitutional because of a change to the nation’s tax laws that Republicans made last year. The White House has said the law will stay in place, pending the appeals process.

Nevertheless, Republicans are under greater pressure to produce an alternative to the law they have ardently opposed since its passage and a means to ensuring affordable health care coverage to some 52 million people with conditions such as diabetes, asthma and cancer. But they are still riven by the divisions that thwarted previous efforts to overhaul the law.

“There are a lot of flaws in the ACA, but there are a lot of very good provisions as well, and tossing it out the window altogether is not the way to go,” said Sen. Susan Collins (R-Maine), who disagreed with Friday’s ruling. “We can’t have our position be to just repeal and not replace the ACA.”

Agreeing on a replacement has been an elusive goal for the GOP, which tried and failed to pass a plan in the Senate last year. Collins notably voted against that plan. With Democrats about to take control of the House, their window for getting an Obamacare alternative to Trump’s desk has effectively closed for the next two years.

However, there is still a political imperative for Republicans to rally around a plan of their own, especially ahead of 2020 elections for president and Congress. Democrats are seizing on Friday’s ruling to highlight the repeated GOP efforts to dismantle the ACA.

“In the midterms, the threat to health-care was theoretical, and now it’s a clear and present danger,” said Jesse Ferguson, a former Democratic Congressional Campaign Committee official.

House Democratic Leader Nancy Pelosi (Calif.) vowed her chamber would “formally intervene in the appeals process” when her party takes power in January. Senate Minority Leader Charles E. Schumer (D-N.Y.) said he will force votes next year that would show Republicans have been dishonest on health care, votes certain to be used in campaign ads. A liberal group is planning to pressure GOP senators up for reelection to oppose the ruling.

“They are trapped by their white-hot hatred of President Obama and everything he did,” said Sen. Chris Murphy (D-Conn.), speaking of Republicans. “And if they stay in that place it will be their undoing as a party.”

While many congressional Democrats spoke out in the hours after the judge’s ruling, Republicans on Capitol Hill were much quieter Saturday. The dynamic resembled this year’s midterm elections, in which Democrats were eager to run on health care and Republicans sought to direct voters’ focus to other topics.

The politics of health care have shifted in recent years. Repealing and replacing the ACA was a rallying cry for Republicans during the President Barack Obama’s terms and a cause for concern for many Democrats. But over time, the law gained popularity, millions of Americans were insured and Obama left office.

Thirty-seven states have expanded Medicaid under the law, with three Republican-leaning states — Idaho, Nebraska and Utah — approving ballot measures last month to expand the health-care program for the poor and disabled.

In the midterms, Democrats made health care their signature issue, positioning themselves as staunch defenders of the law’s well-regarded provisions, most notably its protections for people with preexisting conditions. They cast Republicans as hostile to those provisions, noting their failed 2017 repeal-and-replace effort.

They also highlighted the lawsuit, which was joined by Republican governors and state attorneys general from 20 states. Among them was Josh Hawley, who was elected to the Senate in Missouri despite facing attacks over his decision to join the legal fight.

Hawley was among the Republicans who campaigned on pursuing protections for people with preexisting conditions outside of Obamacare. He advocated a federal insurance guarantee as a potential alternative for ensuring protections.

“Now it’s time for both parties to work together to lower healthcare costs, improve access to quality care for all, and protect those with preexisting conditions,” Hawley wrote Friday on Twitter, responding to the ruling.

Sen. Claire McCaskill, the Democrat that Hawley defeated, had a different take. “@HawleyMO has won the victory he sought in his lawsuit,” she tweeted Friday. “Obamacare has been gutted by a Texas Court due to his lawsuit. Rs promised repeal and replace. They didn’t. Now @HawleyMo has done repeal thru courts. But there’s no replace. Scary stuff for millions.”

House Republican leaders praised Friday’s ruling and pointed to the legislation they passed in their chamber last year to overhaul the health-care law.

“President Trump has made clear he wants a solution and I am committed to working with my colleagues on both sides of the aisle to make sure America’s health-care system works for all Americans,” House Majority Leader Kevin McCarthy (R-Calif.) said in a statement.

What that solution would entail was not clear. A spokesman did not immediately respond to a request seeking more clarity.

Trump on Saturday commented on the ruling against the ACA, telling reporters that he wanted to work with Democrats to pass a new law — without offering specifics or saying how he would do it.

“We’ll get great health care for our people, that’s a repeal and replace, handled a little bit differently, but it was a big, big victory by a highly respected judge, highly, highly respected in Texas,” Trump said.

Senate Majority Leader Mitch McConnell (R-Ky.) did not weigh in on the ruling publicly. A spokesman did not provide any information on his thinking. The day after the midterms, McConnell expressed no interest in a new effort to rip up the ACA in the next Congress.

“I think it’s pretty obvious, the Democratic House is not going to be interested in that,” said McConnell, who suggested instead that lawmakers address the law’s flaws “on a bipartisan basis.”

Republicans expanded to a 53-to-47 Senate majority in the midterms. Still, Schumer promised Saturday to raise the issue of health care in the next session of Congress.

“The GOP spent all last year pretending to support people with preexisting conditions while quietly trying to remove that support in the courts,” he tweeted. “Next year, we will force votes to expose their lies. They will no longer be able to get away with lying to the American people.”

Republican senators will also face pressure from outside the Capitol.

“We’re going to ask every Republican senator, for example, up in 2020, to publicly say they oppose this lawsuit and it should be overturned,” said Leslie Dach, campaign chair of Protect Our Care, an alliance of liberal groups.

One of the Republican senators facing a potentially competitive reelection campaign is Joni Ernst of Iowa. Ernst issued a statement Saturday saying that it was “important that we protect people with preexisting conditions, as we repeal and replace Obamacare.”

She highlighted legislation she has co-sponsored on that front. It has yet to receive a vote.

Josh Dawsey contributed to this report.