The experimental U.S. policy requires migrants to wait in Mexico while their asylum claims are processed. Homeland Security officials said the measure will soon expand to multiple border cities and apply to migrant families. (Luis Velarde /The Washington Post)

A federal judge on Monday blocked an experimental Trump administration policy that requires asylum seekers to wait in Mexico while their cases make their way through the U.S. immigration court system, a major blow to President Trump’s efforts to stem the surge of crossings at the southern border.

U.S. District Judge Richard ­Seeborg in San Francisco enjoined the Migrant Protection Protocols (MPP) policy days after outgoing Homeland Security Secretary Kirstjen Nielsen pledged to expand the program. The policy began in January at the San Ysidro port of entry in California but has been extended to the Calexico, Calif., entry and to the entry in El Paso, and Seeborg wrote that the approach would have been further extended if the court had not stepped in.

Several hundred migrants have been returned to Mexico under the program after seeking asylum at the border.

U.S. authorities at the U.S.-Mexico border fence as seen from Mexicali, Mexico, on Friday. A federal judge has blocked a program that the Trump administration had been using to push asylum seekers back into Mexico to await their court hearings. (Guillermo Arias/AFP/Getty Images)

The ruling — a preliminary injunction at least temporarily stopping the program — paralyzes one of the Trump administration’s last remaining tools to stem the flow of Central American families trying to cross the U.S.-Mexico border, an influx that has hit decade-long highs and has infuriated the president. Trump took out some of that frustration on the Department of Homeland Security in recent days: Nielsen resigned days after the White House rescinded the nomination of one of her top deputies, Ronald Vitiello, to lead Immigration and Customs Enforcement.

In his 27-page ruling, Seeborg said the legal question before him was not “whether the MPP is a wise, intelligent, or humane policy, or whether it is the best approach for addressing the circumstances the executive branch contends constitute a crisis.” Rather, he wrote, the program probably violates the Immigration and Nationality Act, the Administrative Procedures Act and other legal protections to ensure that immigrants “are not returned to unduly dangerous circumstances.”

Justice Department officials ­declined to comment on the ruling Monday. The U.S. government could appeal the ruling to the U.S. Court of Appeals for the 9th Circuit but has not indicated whether it will do so.

In a late-night tweet, Trump lambasted the judge’s decision.

“A 9th Circuit Judge just ruled that Mexico is too dangerous for migrants,” he wrote. “So unfair to the U.S. OUT OF CONTROL!”

The American Civil Liberties Union, one of the groups that filed the lawsuit, cheered the ruling as a “very important decision” on the administration’s “unprecedented” attempt to block asylum seekers from setting foot on U.S. soil.

“What it will mean is that nobody else can be sent to Mexico,” said Judy Rabinovitz, deputy director of the ACLU’s Immigrants’ Rights Project. “They can’t enforce this policy.”

A week ago, Nielsen directed U.S. Customs and Border Protection to “immediately expand” Migrant Protection Protocols along the nearly 2,000-mile border, hoping to return hundreds of additional migrants a day to Mexico, beyond where the program was operating in California and Texas.

The Trump administration has justified blocking asylum seekers from entering the United States by claiming that asylum seekers are trying to carry out a scam — that they are coached to file false asylum claims knowing that they will be released into the country because of a lack of detention bed space and legal limits on how long the government can detain children with their parents.

Migrants who reach U.S. soil — including areas that are outside U.S. border barriers but inside U.S. territory — have the legal right to seek asylum. They generally are either held in detention facilities to await rulings in their cases or are released into the United States.

Advocates for immigrants say the migrants are fleeing poverty and violence in Central America and should be allowed to wait in the United States until their cases are decided.

Seeborg said his order stopping the policy will take effect at 5 p.m. Friday. Within two days, he said, the 11 migrants named in the lawsuit must be allowed to enter the United States. The administration may not implement or expand the program, the judge said.

In the ruling, Seeborg wrote that DHS will still have the authority to detain migrants when they return to the United States, and he made clear that his ruling does not preclude Congress from creating an MPP-style program under federal law. Trump and top administration officials have implored Congress to act to stop the flow of tens of thousands of migrants each month.

“To be clear, the issue in this case is not whether it would be permissible for Congress to authorize DHS to return aliens to Mexico pending final determinations as to their admissibility,” Seeborg wrote.

John Wagner contributed to this report.

Maria SacchettiMaria Sacchetti covers immigration for the Washington Post, including U.S. Immigration and Customs Enforcement and the court system. She previously reported for the Boston Globe, where her work led to the release of several immigrants from jail. She lived for several years in Latin America and is fluent in Spanish. Follow