The high court agreed with insurers that the congressional spending restrictions didn’t release the government from its original promise to fund the Obamacare program. The court said Congress had created "a rare money-mandating obligation" that later appropriations language couldn't repeal.

"These holdings reflect a principle as old as the Nation itself: The Government should honor its obligations," wrote Justice Sonia Sotomayor in the majority opinion.

Justice Samuel Alito, in a dissenting opinion, criticized the ruling as effectively providing a massive bailout for the insurance industry.

"Under the court’s decision, billions of taxpayer dollars will be turned over to insurance companies that bet unsuccessfully on the success of the program in question," Alito wrote.

The decision will have little impact on Obamacare. The law faces a legal threat in a separate case brought by Republican-led states challenging the law’s constitutionality, which the Supreme Court has agreed to hear, likely later this year. But the ruling represents a loss for the Trump administration, which argued it wasn’t obligated to make the risk corridor payments and is supporting the red states’ lawsuit.

The three-year risk corridors program closed in 2016. Insurance experts said the program’s $12 billion shortfall contributed to turbulence in Obamacare’s early years, as health plans jacked up premiums to cover their losses or abandoned the marketplaces.

The Supreme Court case consolidated lawsuits brought by three small insurers, including one that blamed the risk corridors shortfall for its collapse in 2016. Today's decision will also benefit insurers who brought dozens of identical lawsuits in lower courts.

The decision was a "resounding win" for health insurers, but it also raised new questions about what comes next, said Katie Keith, a Georgetown University law professor and expert on the health care law. Those questions include when the money will go out and how the federal government will distribute the funds.

The justices tasked the lower courts with figuring out the nuts and bolts of the settlement, which will add to the delay in insurers receiving the money.

There are also ongoing legal fights over federally funded nonprofit insurance start-ups. Many of these insurers, known as co-ops, shuttered in the law's early years partly because they didn't receive the risk corridor funds they expected. Some of those defunct health plans turned to hedge funds to help them finance their lawsuits in exchange for a piece of the damages if the Supreme Court ruled in their favor.

Insurers hope the decision will also bolster the industry in another pipeline of litigation challenging President Donald Trump’s elimination of a separate Obamacare subsidy program in 2017.

Insurers have filed numerous lawsuits, including a class action suit involving about 100 Obamacare plans, claiming that the federal government broke its promise to fund these so-called cost-sharing reductions, which helped insurers pay poor customers’ medical bills. Those lawsuits have so far been successful in lower courts, but appellate judges who heard arguments last year appeared skeptical of the insurers' case.