Asylum-seeking migrants who cross into Texas or New Mexico can be barred from receiving asylum protection if they passed through another country before arriving at the U.S. border, a federal court ruled Friday.

The ruling by the 9th U.S. Circuit Court of Appeals is a partial victory for the Trump administration, which announced a policy last month that would disqualify most asylum seekers from receiving protection in the United States if they crossed through another country and didn’t first apply for asylum there.

A federal district judge in San Francisco initially halted the measure, aimed at blocking asylum claims from Central Americans, but Friday's decision by the 9th Circuit let the policy stand in Texas and New Mexico while halting it in Arizona and California, which are in the 9th Circuit's jurisdiction.

The ruling could change the fate for thousands of people waiting to apply for asylum in Mexican border cities like Ciudad Juárez, Nuevo Laredo and Matamoros.

The plaintiffs, East Bay Sanctuary Covenant, Al Otro Lado, Innovation Law Lab and the Central American Resource Center, convinced the lower court to approve a nationwide halt to the program. But in their ruling, two of the appeals court judges on the three-judge panel said the lower court “clearly erred by failing to consider whether nationwide relief is necessary. And, based on the limited record before us, we do not believe a nationwide injunction is justified.”

Countries like Mexico have balked at serving as an alternative haven for the surge of migrants that have come north seeking asylum. The United States has an agreement with Canada, which has agreed to act as a safe third country where migrants can claim asylum. The Trump administration signed a similar deal with Guatemala last month, but that country’s incoming president, Alejandro Giammattei, said the agreement needed to be ratified by both countries’ congresses, Reuters reported.

The asylum policy was announced months after the Trump administration expanded its Migrant Protection Protocols program, also called “remain in Mexico,” to the Texas-Mexico border. That policy requires people who have sought asylum to wait in Mexico until their court dates in the U.S. There were roughly 12,000 asylum seekers waiting in Ciudad Juárez as of two weeks ago, state officials said, with an additional 5,000 on a waiting list to request asylum. The majority of those will likely be affected by Friday’s decision if they didn’t first seek protections in another country as they traveled to the U.S.-Mexico border.