On Thursday night, President Donald Trump unveiled his latest attack on the Affordable Care Act: His administration will stop paying cost-sharing reductions to insurers, depriving them of about $9 billion each year. According to the Congressional Budget Office, Trump’s executive order will further roil insurance markets, increase premiums, drive up government spending, and deprive as many as 1 million people of health insurance. It’s worth noting, though, that this move is extremely vulnerable to legal challenges, as well as lawful workarounds that should eventually deliver the payments to insurers.

Obamacare created two types of subsidies to help Americans purchase insurance on exchanges. The first, premium subsidies, offset premiums for individuals who earn less than four times the federal poverty level. These subsidies come in the form of tax credits provided to consumers by the IRS. The second type of subsidy, cost-sharing reductions, help lower-income people pay out-of-pocket spending like deductibles. These come in the form of reimbursements provided to insurers by the Department of Health and Human Services. By law, insurers must reduce out-of-pocket costs for lower-income consumers; HHS then pays them back the money they lost.

Republicans have alleged for years that these reimbursements are illegal, claiming that Congress has not appropriated the funds as required by law. This argument is based on a highly formalistic reading of the relevant statute. While the ACA appropriates premium subsidies, it does not explicitly appropriate cost-sharing reductions. The statute does, however, declare that HHS “shall pay” cost-sharing reductions to insurers, creating a contradiction: HHS must make these payments, but it may not have congressional authority to do so. The ACA’s omission of such an appropriation was almost certainly a regrettable oversight.

The Obama administration noticed this problem and asked Congress to appropriate the funds. This should not have been a controversial request given that insurers are legally entitled to the money. But congressional Republicans refused. The administration, caught in a Catch-22, decided to make the payments anyway, citing its legal obligation to do so. In 2014, the House of Representatives, now in the hands of the GOP, sued in federal court. Many observers assumed the court would quickly toss the lawsuit; it is not at all clear that a legislative body has standing to sue the executive over a dispute about statutory interpretation. But U.S. District Judge Rosemary M. Collyer ruled that the House did have standing to sue—then held that the cost-sharing payments were unappropriated and thus unconstitutional.

Collyer stayed her injunction while the administration appealed, and the litigation has since been in limbo at the U.S. Circuit Court of Appeals for the District of Columbia. (The court granted the House’s request to put the case on hold following Trump’s victory, anticipating a possible shift in the executive’s position.) Collyer’s decision has given Republicans a rallying cry against the ACA, allowing them to assert that Obama’s HHS was paying out cost-sharing reductions illegally. When Trump took office, he was widely expected to cease these payments. Thursday’s move was pretty much inevitable; it’s actually surprising it took him nearly nine months to nix the subsidies.

So: Now what? Congress could just appropriate the money anyway. Republican Sen. Lamar Alexander and Democratic Sen. Patty Murray are currently working on a deal to keep cost-sharing subsidies flowing, but its fate is in doubt: Both House Speaker Paul Ryan and the White House have expressed hostility toward such a deal. Another less palatable option would be for states and insurers to sit back and see how the sabotage plays out. To cover their losses, insurers would have to inflate the cost of premiums, which would, in turn, increase the premium tax credits the government must pay out. Some insurers might also withdraw from the exchanges due to lack of reimbursement. Fewer people would receive coverage, costs would go up for everyone, and the exchanges might implode—all because of the ACA’s sloppy drafting.

There are three ways to avoid this expensive mess. First, and most obviously, states can sue to force the administration to continue paying out cost-sharing reductions. This summer, the D.C. Circuit allowed 18 attorneys general to intervene and defend the subsidies; these attorneys general can now ask the court to block the implementation of Trump’s executive order. Alternatively, these states can file a new lawsuit in a federal district court. (Several attorneys general have already indicated they will do just that.) When Congress passed the ACA, after all, it instructed HHS to make these payments. And in doing so, it effectively appropriated the necessary funds. As Georgetown University law professor David Super explained to my colleague Jordan Weissmann in 2015: “The Supreme Court has been very clear that you do not have to have a law that says ‘appropriations’ across the top. You just need a law directing that the money be spent.”

Second, insurers could sue the federal government to reimburse them for the cost-sharing reductions. Nicholas Bagley, a professor at the University of Michigan Law School, has explained how this would work, and why it would succeed. The federal government keeps a permanent appropriation called the Judgment Fund that pays court judgments when “payment is not otherwise provided for.” Insurers could sue in the Court of Federal Claims and would likely win given the ACA’s unequivocal command that these payments be made. As Bagley put it: “The question is thus not whether the government will pay, but when.”

There is already precedent for this type of litigation. The ACA includes a “risk corridor” program to encourage insurers to offer health plans on exchanges. This initiative directs HHS to collect money from health plans that exceed their financial targets and redistribute it to plans that lose money. But Congress failed to include an explicit appropriation for the program. Moreover, congressional Republicans kept attaching a rider to appropriations bills that prevented HHS from redistributing these funds. Eventually, insurers sued to get the money they were owed under federal law. The Court of Federal Claims has repeatedly found in their favor, ordering the government to pay out hundreds of millions of dollars to insurers. Trump’s retraction of cost-sharing subsidies will provoke similar suits and awards.

A third and final solution, one proposed by Slate contributor and University of Chicago Law School professor Daniel Hemel, combines these first two approaches. Hemel has urged states to make cost-sharing payments themselves, then sue the federal government to recover the money from the Judgment Fund. As Hemel put it to me in an interview on Friday, these states would “step into the shoes of the insurers in any litigation against the feds” at the Court of Federal Claims. Meanwhile, they can continue paying the amount that HHS was required to pay from their own budgets. Presumably, only progressive states would participate in this plan, but their actions could help stabilize the ACA at a time when such stabilization is desperately needed. “It seems irresponsible for states not to save their exchanges when they have the opportunity,” Hemel said.

Congressional Republicans could counter the Judgment Fund option by passing a law barring any payout from the fund in cost-sharing litigation. But as Bagley has written, this dramatic step “would amount to a government default on its obligations.” Nothing is off the table with this administration, but it is doubtful that Congress would resort to debt default to prevent insurers from receiving the money they’re owed.

There is at least one other possible path to victory for Trump and the GOP: ideologically motivated judges. Seven of the 10 judges seated on the Court of Federal Claims were appointed by Republicans. The court is not especially partisan; the judge who ordered the government to make huge risk corridor payouts, for example, was appointed by George W. Bush. But that impartiality could soon change. There are six vacancies on the court, and Trump has already nominated candidates to fill three of them. One has called Justice Anthony Kennedy a “judicial prostitute”; another has practiced law for just nine years—never before the Court of Federal Claims—and rose to prominence defending an anti-transgender school board. Judges on the court are not bound by each other’s rulings, and it is easy to envision a group of highly partisan judges ruling against the ACA on political grounds.

There’s no guarantee, then, that the courts will step in to save Obamacare. But these potential legal challenges do have a genuine chance of succeeding—and, in the process, thwarting Trump’s most dangerous (and expensive) attempt yet to sabotage Obamacare. The ACA is clear: HHS must keep paying out cost-sharing subsidies to insurers whether it wants to or not. Trump has no authority to destroy the ACA by rewriting it. The cost-sharing money must keep flowing. If Trump wants to cut off those funds, he cannot merely sign an executive order. He must convince Congress to change the law itself.