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 ensure affordable health care coverage to some 52 million people with conditions such as diabetes, asthma and cancer. But they still are 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 still is 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, of California, 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 on 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 Obama presidency 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 tweeted on Friday, responding to the ruling.

Sen. Claire McCaskill, the Democrat Hawley defeated, had a different take. โ€œ@HawleyMO has won the victory he sought in his lawsuit,โ€ she tweeted on 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 flaws in the Affordable Care Act โ€œon a bipartisan basis.โ€

Republicans expanded their Senate majority to 53-47 in the midterms. Still, Schumer promised on 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 also will 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, the campaign chairman 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 on Saturday saying that it was โ€œimportant that we protect people with pre-existing conditions, as we repeal and replace Obamacare.โ€

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