SAN DIEGO — A federal appeals court ruled Tuesday that the Trump administration can make asylum seekers wait in Mexico for immigration court hearings while the policy is challenged in court, handing the president a major victory, even if it proves only temporary.

The 9th U.S. Circuit Court of Appeals — a frequent target of the president's complaints — reversed a decision by a San Francisco judge that would have prevented asylum-seekers from being returned to Mexico during the legal challenge.

The case must still be considered on its merits and could end up at the Supreme Court. But allowing the policy to remain in effect in the meantime lets the administration carry out an unprecedented change to U.S. asylum practices.

The administration has said it plans to rapidly expand the policy across the border, which would have far-reaching consequences for asylum seekers and Mexican border cities that host them while their cases wind through clogged U.S. immigration courts. Cases can take several years to decide.

The policy was challenged by 11 Central Americans and advocacy groups that argued it jeopardized asylum seekers by forcing them to stay in Mexico, where crime and drug violence are prevalent.

U.S. District Court Judge Richard Seeborg agreed April 8 and said the policy should be halted because it failed to evaluate the dangers migrants faced in Mexico.

The administration introduced its "Migrant Protection Protocols" policy on Jan. 29 in San Diego and later expanded it to Calexico, California, and El Paso, Texas. Under the policy, asylum seekers report to a border crossing in the morning. The U.S. government provides transportation to immigration court and returns them to the border after the hearing.

The U.S. has returned 3,267 Central American asylum seekers through three border cities, Mexico's immigration agency said Monday.

The administration briefly halted the policy after Seeborg's ruling but resumed on April 16, sending 673 people to Tijuana from San Diego since then, 298 to Mexicali from Calexico and 967 to Ciudad Juarez from El Paso.

The policy was introduced to deal with a growing number of asylum-seeking families from Guatemala, Honduras and El Salvador arriving at the U.S. border with Mexico. Under a court order, children generally cannot be detained more than 20 days, which has led to widespread releases of families almost immediately after they are stopped by authorities.

The January launch followed months of delicate talks between senior U.S. and Mexican officials that culminated in dual announcements after a meeting in November in Houston. Both sides characterized it as a unilateral move by the Trump administration and Mexican officials have made clear that they do not endorse the policy.

The three-judge appeals court panel cited Mexico's position to reject the argument that asylum seekers were at risk.

The judges said the "likelihood of harm is reduced somewhat by the Mexican government's commitment to honor its international law obligations and to grant humanitarian status and work permits to individuals returned under the (Migrant Protection Protocols)." In fact, Mexico said Dec. 20 that it would allow foreigners to apply for a work permit, not necessarily get one.

Judge Diarmuid O'Scannlain, who was appointed by President Ronald Regan, offered the strongest backing for the administration's position. Judges William Fletcher, an appointee of Bill Clinton, and Paul Watford, who was named by Barack Obama, were more critical.

The American Civil Liberties Union, Southern Poverty Law Center and Center for Gender & Refugee Studies sued over the policy.

Omar Jadwat, director of the ACLU's Immigrants' Rights Project, said remarks by two of the three judges give reason to believe that the policy will eventually be halted but also raised concern about the impact of Tuesday's decision.

"Asylum seekers are being put at serious risk of harm every day that the forced return policy continues," he said.

Justice and Homeland Security Department officials did not immediately respond to requests for comment late Tuesday, and neither did Mexico's Foreign Relations Secretary officials.

Mexicans and children who travel alone are exempt from the policy.