A federal appeals court in California halted the Trump administration’s “remain in Mexico” immigration policy on Friday, a blow to the president’s restrictive immigration agenda that cripples one of the government’s approaches to curbing migration across the U.S. southern border.

The program — officially known as the Migrant Protection Protocols, or MPP — called for pushing asylum seekers back into Mexico to await their U.S. asylum hearings, part of an effort to limit migrant access to U.S. soil and to lessen a record migration surge among Central American families. More than 470,000 parents and children crossed into the United States last fiscal year, and most were quickly freed into the country to await U.S. immigration court hearings after they claimed asylum.

The Trump administration has claimed that the migrant families have been exploiting loopholes in U.S. law to secure their release, knowing of the court-mandated 20-day limit for detaining children. The MPP program was designed to prevent families from entering the United States and later skipping their court hearings to avoid deportation; instead, families have been sitting on the Mexico side of the border.

The Ninth Circuit Court of Appeals ruled 2-1 to uphold a lower-court’s injunction on MPP, saying that the policy “is invalid in its entirety due to its inconsistency with” federal law, and “should be enjoined in its entirety.”

Judges Richard A. Paez and William A. Fletcher, both appointed by President Bill Clinton, voted to uphold the injunction, while Ferdinand F. Fernandez, a President George H.W. Bush appointee, disagreed.

The judges agreed with a lower-court judge that MPP likely violated federal immigration law by ousting undocumented asylum seekers who are supposed to be allowed to apply for protection inside the United States. The judges also said the program likely violated the United States’ “non-refoulement” obligations under international and domestic law, which prohibit the U.S. government from sending people to a country where they could face persecution. The 57-page ruling cited multiple examples of Central American asylum seekers who feared kidnapping, threats and violence in Mexico.

The administration has been working to cut down on its use of MPP in recent months by fast-tracking deportation hearings and sending migrants from Central America by airplane to Guatemala as part of an agreement that allows them to seek asylum there instead. The policies, working together, have been credited with slowing the flow of migrants northward. The number of people waiting in Mexican border cities for U.S. immigration court dates has dwindled, in part because migrants said they were not making the trek to the United States in the first place given how unlikely it would be that they would gain entry.

It is unclear what halting the policy might do to that mind-set, and whether its absence could spur another surge in immigration among Central Americans. It is likely that many of the people waiting in Mexico for U.S. court hearings could now try to re-enter the United States in coming days.

The ruling came on the same day Mexico announced its first coronavirus case, a traveler returning from Italy, raising potential fears about what a run on the U.S. border could mean.

Sanitary conditions are abysmal in the squalid border camps where thousands of would-be asylum seekers are camped out while awaiting a chance to appeal for humanitarian protection in the United States.

One former Department of Homeland Security official said the court decision could prompt the White House to invoke emergency executive powers to impose even tighter restrictions on asylum seekers at the border. One legal provision, known as “Return to Territory,” gives U.S. border officials broad powers to compel a foreign national to go back to Mexico or Canada if that person is deemed inadmissible.

“This ruling couldn’t come at a worse time,” said the former official, who spoke on condition of anonymity to maintain ties to the administration.

The same three-judge panel issued a separate 3-0 ruling blocking Trump’s first so-called asylum ban, which aimed to bar immigrants who crossed the border illegally from seeking asylum. The policy was temporarily halted in 2018. Trump blasted the lower-court judge in the case for being an “Obama judge,” prompting a public rebuke from Supreme Court Chief Justice John G. Roberts Jr., who sided with the court’s four liberal justices months later to let the injunction stand.

Roberts and other conservative justices have since allowed other Trump policies to unfold despite pending lawsuits against them, including one policy that decrees migrants ineligible for asylum if they passed through another country where they could have sought refuge on their way to the United States.

The American Civil Liberties Union cheered the decisions Friday.

“The two cases combined are an important step to restoring the United States’ long-standing commitment to protecting vulnerable people fleeing persecution,” said ACLU lawyer Lee Gelernt.

After MPP officially began in January 2019, it quickly became a central aspect of the Trump administration’s bulwark against immigration. It expanded significantly in June, when Mexico agreed to host thousands of migrants and to crack down on smugglers after Trump threatened to impose tariffs on Mexico’s exports to the United States.

Approximately 59,000 migrants from countries including Cuba, Honduras, Guatemala, El Salvador and Venezuela have been sent back to Mexico to wait until their asylum cases could be heard in the United States. U.S. officials said the program had a powerful deterrent effect at the border.

Homeland Security officials have credited MPP and other policies with a 71% drop in the number of migrants taken into custody at the border since the peak of 144,000 in May.

Federal officials had blamed the surge of migrant families on smugglers who were exploiting U.S. law and were persuading Central Americans to sell their houses, take out loans, and travel with a child to the United States with promises that families could speed through the immigration bureaucracy.

Acting Customs and Border Protection Commissioner Mark Morgan blamed smugglers for enticing migrants to pay exorbitant fees for the trip to the United States and exposing children to the dangerous journey because they were more likely to be released to await a court hearing. But he said the MPP program was “telling the cartels and this vulnerable population the game has changed.”

“It used to be, you come here with a kid, that was your passport into the United States,” he told reporters at a Sept. 9 White House briefing. “MPP is saying, ‘That’s done. That’s a lie now. You can’t. You’re not going to be allowed into this country even if you bring a kid.' So don’t mortgage your home. Don’t pay the cartels. Don’t risk your life. Don’t risk the life of your family. When you get in here, don’t allow yourself to continue to get exploited. That’s what MPP is doing.”

Though the Ninth Circuit’s decision almost certainly will be appealed, for now it stops the policy nationwide. The Trump administration had been declaring near-victory in stemming immigration just weeks ago, in part because of MPP’s success.

Ken Cuccinelli, acting deputy secretary of DHS, said last month that attempting to cross into the United States is “essentially futile at this point” and that “illegal migrants are going to be promptly returned.”

But thousands are still trying, and more might follow as temperatures warm in the coming months.

“We are not unmindful of the possibility that while the flows have gone down for seven months, they can go back up, and we’re preparing to handle that as well,” Cuccinelli said at a media briefing.

MPP and other measures are “critical to averting a further crisis” on the border, he said. The Trump administration also has brokered agreements with countries in Central America to absorb people the United States rejects and has accelerated plans to add hundreds of miles of new fencing along the nearly 2,000-mile border.

Advocates for immigrants say MPP and other enforcement measures forced families with young children to await their hearings in crime-ridden Mexican border cities where their lives are in danger.

Human Rights First, an advocacy group, said it has documented more than 800 reports of rape, kidnapping, and other violent attacks against asylum seekers forced to return to Mexico under MPP.

Justice Department lawyers have called those claims “speculative” and have said the program is “one of the few congressionally authorized measures available” to control the border.

But Morgan, who initially said that Mexico had not advised the U.S. government of any attacks, acknowledged in December that some reports of violence were true. He said migrants would not be at risk if they stayed inside the “shelter environment.” Human Rights First said migrants also have been targeted in shelters.

Morgan said U.S. policy is not to blame for the attacks, “if there’s an act of violence in Mexico, there’s only one person to blame. And that’s the individuals who committed that act of violence.”

But federal judges have expressed deep concerns about whether the U.S. government is violating the internationally agreed upon principle of “non-refoulement,” which says nations will not send foreign nationals to countries where they could face persecution.

A federal judge in California initially halted MPP, but in May a three-judge panel on the Ninth Circuit allowed the program to resume until another set of judges could hear arguments over its legality.

Two of the three judges on that earlier panel expressed concern about migrants’ safety in Mexico. One judge said it seemed “irrational” to send migrants to Mexico without asking them whether they were afraid to return there, while another said the government is “clearly and flagrantly wrong.”

During a hearing on Oct. 1, some judges on a separate panel questioned Justice Department lawyers about the administration having sent migrants into Mexico without asking them if they fear for their safety.

Judge William Fletcher said the U.S. government is doing little to protect migrants at the border, saying “you’re giving them nothing.”

“You’re not even asking the key question with respect to refoulement, that is to say, ‘Are you afraid?’” he told Justice Department lawyer Scott Stewart during the hearing.