As the coronavirus pandemic spreads across the United States, some states and localities are scrambling to release people from jail. Reducing incarcerated populations is critical to stopping the spread of the virus; if jails, prisons, and immigrant detention centers remain packed, they will become an epicenter of the outbreak. Yet the Trump administration has continued to fight for the power to force states and localities to detain immigrants in local jails. It’s good news for public health, then, that the 1st U.S. Court of Appeals ruled on Tuesday that the administration’s assault on sanctuary cities is illegal. The panel’s unanimous decision—joined, notably, by retired Supreme Court Justice David Souter—affirms cities’ right to keep unauthorized immigrants out of their own jails and help them avoid federal detention.

Trump’s Department of Justice has long sought to punish “sanctuary” jurisdictions, those hundreds of cities, counties, and states that refuse to enforce federal immigration laws. Most sanctuary jurisdictions prohibit local law enforcement from asking about immigration status, arresting people because of their immigration status, or informing the federal government when it detains a person who happens to be undocumented. These jurisdictions also forbid jails from extending the detention of unauthorized immigrants so federal agents can take them into custody.

The DOJ has no constitutional authority to simply commandeer local police into enforcing immigration law. So, instead, the agency sought to cut off sanctuary jurisdictions from the leading source of federal funding to local law enforcement, the Edward Byrne Memorial Justice Assistance Grant Program, if they did not explicitly agree to cooperate with immigration enforcement. This move would deprive these jurisdictions of millions of dollars in federal funding each year, potentially coercing them into abandoning their sanctuary policies.

Before Tuesday, the 3rd, 7th, and 9th U.S. Circuit Courts of Appeals had already found that the Justice Department has no authority to slash funding for sanctuary cities and states. Only the 2nd U.S. Circuit Court of Appeals upheld the DOJ rule in a frightening decision that suggested the federal government can require local cops to serve as immigrant enforcers. The 1st Circuit rejected that logic, siding against the DOJ rule in an opinion by Judge Bruce Selya (a Ronald Reagan appointee) joined by Judge David Barron (a Barack Obama appointee) and Souter. (Justices can sit on federal courts of appeals after they retire from the Supreme Court.)

The fundamental problem with the Justice Department’s attack on sanctuary jurisdictions, Selya explained, is that it’s totally unauthorized. Federal agencies don’t have the power to impose new conditions on funding to the states. Rather, Congress must authorize those conditions, within constitutional limits that bar the “commandeering” of state officials. Here, Selya wrote, the DOJ tried to “stretch the statutory language beyond hope of recognition.” Congress did require Byrne/JAG recipients to share certain information and “coordinate” with the federal government. But these conditions apply only to activities funded by Byrne/JAG grants. (For example, recipients must use some of the money to purchase police equipment and develop training materials.) The DOJ’s “implausible” claim that grant recipients must turn over all information to the feds “conflicts with the plain meaning of the statutory text.”

To defend its actions, the DOJ cited a smattering of other statutes that purportedly give it discretion to cut grants on the basis of the attorney general’s policy preferences. But, Selya concluded, it “has not pointed” to any “statute or regulation” that actually “gives such authority” to the agency. To determine who gets grants, Congress created “a detailed formula that takes into account population and violent crime statistics.” Jurisdictions that satisfy this standard must get grants. There are a few exceptions—for instance, the DOJ can withhold 10 percent of a grant from states that don’t maintain a comprehensive sex offender registry. But there’s no exception for immigration enforcement. The statute “simply does not allow the DOJ to impose by brute force conditions on Byrne/JAG grants to further its own unrelated law enforcement priorities.”

Tuesday’s decision ensures that law enforcement in states within the 1st Circuit—Maine, Massachusetts, New Hampshire, and Rhode Island—can maintain their sanctuary policies without risking federal funds. (The two Rhode Island cities that brought this lawsuit, Providence and Central Falls, have sanctuary policies; so does the entire state of Massachusetts.) Local police have no obligation to report undocumented immigrants to Immigration and Customs Enforcement. Nor must they detain immigrants who would otherwise be released so ICE agents can transfer them to detention centers where COVID-19 is already spreading. Although the 1st Circuit did not take public health into account, its ruling will keep countless people out of jail and lessen the impact of outbreaks behind bars.

The ruling also contributes to a growing consensus in the federal judiciary that the Trump administration’s anti-sanctuary policies are obviously illegal. Given that the 2nd Circuit bucked this trend, however, the Supreme Court is all but certain to resolve this issue. One retired Supreme Court justice, Souter, has already sided against the administration. The question now is whether five sitting justices will agree with him. These cases are a test of the conservatives’ commitment to upholding the plain text of the law while respecting states’ constitutional prerogative to set their own law enforcement priorities. Immigration advocates can only hope that Souter’s former colleagues share his commitment to the rule of law.