Republicans fought the health care law and the health care law won.

It was a close call, closer perhaps than many people realized. Had Republicans kept control of Congress in this year’s midterm elections, they would almost certainly have made another attempt to repeal the Affordable Care Act. If anything, the result might have emboldened them, by convincing them that they could survive the kind of political backlash that their failed 2017 effort produced.

But as of Tuesday evening, Republicans were set to lose their majority in the House of Representatives, with only the size of a new Democratic majority in question. And health care was a big reason why Republicans performed as badly as they did.

This was an election about immigration and the environment, Brett Kavanaugh and Donald Trump, but voters consistently told pollsters that health care was foremost on their minds.

And it was the GOP’s repeal effort specifically that ended up causing the party so many problems, in no small part because Democrats did everything they could to make it an issue. In district after district, state after state, Republicans came under withering attack for trying to take away Medicaid and, especially, for trying to take away protections for people with pre-existing conditions.

Republicans tried to change the subject and, when that wouldn’t work, they decided their best strategy was to lie ― to pretend they hadn’t spent eight years trying to strip away those pre-existing condition protections and the rest of the Affordable Care Act with it.

Those arguments may have helped some Republican Senate candidates win close races. But they didn’t save the GOP’s House majority, which means the health care law has all but surely survived yet another near-death experience ― the latest in a string of trials that includes the Democrats losing their filibuster-proof Senate majority in 2010, a pair of Supreme Court cases in 2012 and 2015, the failed launch of the online insurance markets in 2013, and most recently the GOP repeal effort of 2017.

In fact, the most immediate, practical consequence of the election could be something quite the opposite of repeal. A few hundred thousand more people could get health insurance through Medicaid, because states that had resisted the Affordable Care Act’s expansion of the program could finally be joining.

Ballot initiatives to expand the program, as 33 states plus the District of Columbia have already done, won in Idaho, Nebraska and Utah Tuesday. A measure to renew an existing expansion program in another conservative state, Montana, failed.

Medicaid expansion could also come to one other traditionally conservative state, Kansas. The state legislature approved legislation to expand the program last year, only to have then-Gov. Sam Brownback (R) veto it.

On Tuesday, Republican Kris Kobach lost his gubernatorial bid to Democrat Laura Kelly. She has pledged to approve an expansion bill within her first year of office.

Republicans Haven’t Given Up ― And May Never Give Up

Despite these results, nobody familiar with the history of the 2010 law, or health care policy more generally, would assume that fights over the program are over ― or that it is sure to be standing a few years from now.

A lawsuit from 20 Republican state officials claiming that the law is unconstitutional now sits before a federal judge in Texas. The merits of the case are weak, as even longtime Affordable Care Act critics concede. But it’s entirely possible it will prevail, setting up future appeals and perhaps injecting yet more chaos into insurance markets, because the judge is a conservative Republican appointee and the lawsuit has the backing of Trump’s Justice Department.

It’s an unusual move. Typically the Justice Department would defend a federal law, even if the administration in power doesn’t like it.

But the decision to join was just one example of the ways the Trump administration has found to use executive authority to undermine the law, something it will continue to do as long as it controls the executive branch. While the state officials are seeking to get the entire law thrown out, Attorney General Jeff Sessions asked the judge to only invalidate the provisions of the law protecting people with pre-existing conditions.

Just last month, the Trump administration announced it would be proposing new regulations that would give states leeway to rewrite the rules of their own insurance markets, by scaling back the regulations on pre-existing conditions and even allocating financial assistance differently. This was the administration’s latest move to weaken the Affordable Care Act’s consumer protections. Trump’s government also severely cut back on health insurance exchange outreach and enrollment programs.

The Trump administration and Republican-led states will be able to continue such efforts and to impose restrictions on Medicaid eligibility. The administration already has approved plans in Arkansas, Indiana, Kentucky, New Hampshire and Wisconsin that impose work requirements on some adult Medicaid beneficiaries (although a court struck down Kentucky’s plan). Nine other states have applied for work requirements the administration is almost certain to okay.

The reality is that Republicans will never stop trying to weaken, undermine and ultimately eliminate the Affordable Care Act, just as they have never given up on trying to privatize Medicare and dramatically cut Medicaid.

But the Medicare example is instructive, because it shows what happens when a program has become too popular to dislodge. Republicans portray themselves as defenders of Medicare, even as they are trying to scale back and transform it into a private program, because they know that a frontal, unambiguous political assault would invite such a strong popular backlash.

This election may signal that the Affordable Care Act has reached the same threshold or is at least getting a lot closer. The program still isn’t as popular, with polls showing that only small majorities have favorable views of it, but that’s an improvement over what the same polls showed just two years ago.

It may be that by trying to repeal the health care law, the law’s critics have done what it never could do on its own: shore up support not just for the law’s specific provisions, but for the very idea that people should get health care even if they are sick and even if they can’t pay for that care on their own.

Not that the Affordable Care Act has actually realized that goal. The number of people without health insurance is at historic lows, but many millions still have no coverage and even among those with insurance, many millions are struggling to pay their bills.

Some are in trouble because they make too much money to qualify for financial assistance and the comprehensive insurance sold under Affordable Care Act regulations, with its guarantees of benefits for all, is too expensive for them to afford on their own.

Others are in trouble because they have employer-sponsored coverage and the out-of-pocket costs keep getting higher. This isn’t a problem that Obamacare created so much as one it didn’t solve: Health care still costs more in America than it does in any other country.

Where Democrats Might Go From Here

Now that Democrats control congressional committees, one of their main focuses will be using subpoena power to oversee, and investigate, how the Trump administration is managing federal health programs.

Likely topics for investigation include the Trump administration’s decisions to cut that outreach spending; to allow states so much leeway in rewriting their insurance market rules; and to grant requests for work requirements and other limitations on Medicaid coverage. Some of these choices involved questionable uses of executive authority and that is precisely the sort of thing Democratic congressional committees would want to scrutinize.

But there’s a presidential election coming in two years and, at least within the Democratic Party, this campaign is likely to feature a conversation that started in the last one ― when Bernie Sanders, the independent senator from Vermont, made his proposal for a single-payer, “Medicare for All” system a centerpiece of his 2016 presidential campaign.

Since that time, more than a dozen Democratic senators, including many presidential hopefuls, have endorsed the idea. Some of them have joined colleagues in promoting alternative plans that also envision large expansions of government-run insurance, along with government control over health care prices, but would not change the system as radically as would the Sanders plan.

The common element in these ideas is an effort to complete the party’s work, from enactment of Medicare up through the implementation of the Affordable Care Act, to make sure everybody can get health care.

Whether they settle eventually on something that could be called Medicare for All or opt for a more modest approach that includes some mix of more subsidies, government control over prices and new government-run insurance programs, a Democratic House could be the proving ground for these ideas and the place where the party will have to coalesce about what to do next.

Republicans will be part of this debate, too. During the final weeks of the 2018 campaign, Republicans tried to make Medicare for All a big issue ― insisting that all Democrats supported it and then insisting it would destroy American health care, and Medicare itself in particular. Those attacks might resonate more in the coming months or coming years. They might not.

Either way, they don’t give Republicans what they have always lacked and apparently still lack: a conservative health care plan that would result in health care for more people, not fewer. And the American public seems to grasp that, even though health care is such an infamously confusing subject.

It goes a long way to explaining why Trump and his Republicans aren’t claiming victory after Tuesday night, and why millions of people who have gotten health care through the Affordable Care Act will get to keep it ― at least for now.

This article has been updated to reflect the final result of a ballot initiative in Montana to retain the state’s Medicaid expansion.

CORRECTION: A previous version of this article misidentified the Kansas governor as Kris Kobach, who is Kansas secretary of state and was running for governor for the first time. It was Gov. Sam Brownback who vetoed Medicaid expansion.