A federal judge in California ruled that the Trump administration can no longer return Central American asylum seekers to wait in Mexico before (and between) hearings in their asylum cases.

The policy, known as the “Migrant Protection Protocols” or the “Remain in Mexico” policy, has resulted in more than 600 asylum seekers being sent back to Mexico since late January — with more than 250 of those coming in the last two weeks, as the Department of Homeland Security (DHS) aggressively expanded its use along the US-Mexico border at the direction of former department Secretary Kirstjen Nielsen.

The new ruling by Judge Richard Seeborg of the Northern District of California, in the lawsuit Innovation Law Lab v. Nielsen, requires the administration to allow people who have already been returned to stay in the US after their next court hearings, and to stop returning new people to Mexico under the policy.

The ruling maintains that the Immigration and Nationality Act’s provision allowing the government to return migrants to a “contiguous country” while their cases are pending does not apply to asylum seekers, and that the way the Trump administration was implementing the policy — returning asylum seekers until they met an unusually high standard of proving they would be persecuted in Mexico — failed to protect migrants from danger.

Seeborg’s ruling comes as the department is already in upheaval. Nielsen resigned under pressure from President Donald Trump on Sunday night; Customs and Border Protection Kevin McAleenan (who helped oversee the implementation of the “Remain in Mexico” policy) has been named her acting replacement, apparently in contradiction of federal vacancies law.

The other DHS official responsible for overseeing the implementation of the return-to-Mexico policy, US Customs and Immigration Services Director Francis Cissna — whose agency included the asylum officers that engaged in infrequent and unusual screenings of asylum seekers who claimed to be afraid of being returned to Mexico — is reportedly under pressure from Stephen Miller, a Trump aide and immigration hawk, to leave as well.

The new ruling is yet another setback for all of them to deal with. Nearly every major Trump immigration initiative has been put on hold by the courts — giving the administration a dwindling array of options as it tries to address the needs of the unprecedented number of families entering the United States and the ongoing temper tantrums of a president who appears to believe they can be prevented from entering.

Ironically, Nielsen introduced the “Remain in Mexico” policy the last time it looked like she might lose her job, in December, as Trump was openly contemplating replacing her in a post-midterms shakeup.

When she presented the plan at a House Judiciary Committee hearing, she made it seem like a central solution to the problem of asylum seekers — one that prevented them from being able to abscond into the United States before their hearings because it didn’t really allow them into the US at all.

The government will almost certainly appeal Seeborg’s ruling — adding it to a long line of Trump immigration policies stuck between a West Coast judge’s injunction and the Supreme Court. It’s plausible that if the administration wanted to fight the case aggressively, they could get the conservative Court to uphold the policy eventually. But it would take months or years. Trump has shown repeatedly — not least over the past few days — that he is not willing to wait that long.