Two people stand at the base of the US Supreme Court in Washington, DC, March 16.

The United States government must pay health insurance companies $12 billion because of a Republican move to undermine the Obamacare markets, the Supreme Court ruled Monday.

The case centered around an Affordable Care Act program to shield insurance companies from risk. Republicans opposed the program and in 2014 Congress essentially repealed it by stripping it of funding.

But in an 8–1 ruling released Monday, the court found that Congress created a legal commitment when it passed the ACA that Congress cannot renege on by refusing to cough up the money.

“These holdings reflect a principle as old as the Nation itself: The Government should honor its obligations,” says the ruling written by Sonia Sotomayor.

Samuel Alito dissented, saying he would have requested supplemental briefings and rearguments next term.

The case in some ways encapsulates the last decade of the national fight over health care. Republicans in Congress have been unable to repeal and replace the ACA, but they have taken various steps to make it less functional. The chaos resulted in many insurers going bankrupt. Others jacked up premiums to compensate for losses or left the markets altogether, resulting in higher costs for consumers and less competition.

The supposed trade-off was less government spending. But with Monday’s ruling, the government will end up paying insurance companies anyway, long after the damage is done. Some amount of the $12 billion will eventually make its way back to consumers in the form of rebates.

When the Affordable Care Act passed no one knew how much it would cost to cover the new rules such as mandating insurers to cover people with preexisting conditions. So the law created a three-year program called "risk corridors" to limit the risk of companies taking part in the new Obamacare marketplaces.

If an insurance company priced its plans too low and lost money, the government would cover the losses after a certain point. Conversely, if an insurer made money it had to pay its profits to the government after a certain point. The goal was to provide stability in the early days when companies were still figuring out the markets.

Most insurers underestimated costs and suffered losses. In 2014, the first year of the program, profitable insurers paid the government $362 million while the government owed unprofitable plans $2.87 billion, a net loss of $2.5 billion. Net losses totaled $5.5 billion the following year and $4 billion in the third and final year of the program.

Sens. Marco Rubio and Jeff Sessions were among the Republicans leading the charge against the risk corridor program. Rubio, at the time vying for the Republican presidential nomination, described risk corridors as a taxpayer-funded bailout for the insurance industry.

Republicans succeeded in cutting off funding for risk corridors. The program could only pay out the money it took in, meaning insurers received pennies on the dollar from what they were owed. The industry sued.

The Supreme Court found that the ACA’s language — the government “shall” make the risk insurance payments — created a legal obligation that Congress cannot undo by failing to appropriate funds.

The risk corridor saga is just one of the legal battles involving the ACA. There are several lawsuits working their way through the courts over the Trump administration’s canceling of another program to backstop insurance plans. Most prominently, Republican-led states are suing to have the entire ACA thrown out. The Trump administration is supporting them. The Supreme Court will hear that case later this year.