Delivering a painful defeat to the Trump administration's most sweeping effort to single-handedly overhaul the asylum system without Congress, a federal judge on Wednesday blocked a rule that made most migrants from Central America and other countries ineligible for asylum at the U.S.-Mexico border.

Judge Jon Tigar of the U.S. District Court for the Northern District of California agreed to issue a temporary injunction halting the policy while he reviews the merits of a legal challenge spearheaded by the American Civil Liberties Union (ACLU).

In his order, Tigar seemed to agree with the concerns raised by the plaintiffs that policy could result in the U.S. government sending asylum seekers back to dangerous circumstances just because they did not seek protection in countries like Mexico. The judge noted Mexico does not have as robust of an asylum system as the U.S. to guarantee people safe haven.

Get Breaking News Delivered to Your Inbox

"An injunction would vindicate the public's interest — which our existing immigration laws clearly articulate — in ensuring that we do not deliver aliens into the hands of their persecutors," Tigar wrote in his 45-page order.

Central American asylum seekers who illegally crossed the Rio Grande nearby wait to be transported to a processing facility after turning themselves in to U.S. Border Patrol in Los Ebanos, Texas, U.S., June 28, 2019. LOREN ELLIOTT / REUTERS

Earlier on Wednesday, a federal judge in Washington declined to block the policy as requested by plaintiffs in a second court challenge to the controversial policy.

The rule facing this court challenge restricts access to the U.S. asylum system for non-Mexican migrants who traveled through Mexico and other countries to reach the southwestern border, but did not seek protection in those nations. Although designed to stem the flow of Central American migrants journeying north, the regulation also affected people from other parts of the world trying to reach the U.S. through Mexico — including Cubans, Venezuelans, Brazilians and central Africans, who have traveled to the U.S.-Mexico border in higher numbers this year.

The joint regulation represented a drastic change in the asylum system for migrants seeking refuge at the southern border. Before the rule, migrants who crossed into the U.S. illegally were allowed to claim asylum after being apprehended by Border Patrol officers. Most asylum-seeking families were typically released from immigration custody after less than 20 days in detention and allowed to remain in the U.S. while their cases were adjudicated.

Late last year, Tigar blocked a similar effort by the administration to prohibit migrants who cross the border illegally from being able to seek asylum.

Melissa Crow, a senior supervising attorney at the Southern Poverty Law Center's Immigrant Justice Project, one of the groups that joined the ACLU in the San Francisco court challenge to the new rule, praised Tigar's ruling on Wednesday.

"Today's ruling is an important victory for incredibly vulnerable individuals and families from besieged Central American countries seeking refuge in our country," Crow said in a statement. "We will continue to fight this draconian policy as well as the myriad of others through which the Trump administration continues to wage war on asylum-seekers and our nation's asylum system."

Soon after the regulation took effect last week, two lawsuits — including the one spearheaded by the ACLU — were filed to block the policy. The plaintiffs argued that the regulation was devised contrary to federal rule-making procedures and violated the 1952 Immigration and Nationality Act (INA), which allows most who set foot on American soil to seek asylum if they fear persecution in their homeland.

The complaint filed by the ACLU and other groups in San Francisco said the new rule violated that core provision in U.S. law. The plaintiffs also noted that Congress, under the the INA, stipulated that the government could deport asylum seekers to a third country to seek safe haven only if the U.S. and said nation were part of a bilateral or multilateral agreement.

"The Rule is a part of an unlawful effort to significantly undermine, if not virtually repeal, the U.S. asylum system at the southern border, and cruelly closes our doors to refugees fleeing persecution, forcing them to return to harm," the petition read.

In a rare public rebuke of domestic U.S. policy, the Office of the United Nations High Commissioner for Refugees — which receives U.S. funds — denounced the regulation as a "severe" effort that was not "in line" with international obligations for refugees.

"It will put vulnerable families at risk," High Commissioner Filippo Grandi said earlier in the week, noting that many migrants do find "effective international protection" in the countries they travel through to get to the U.S.-Mexico border. "It will undermine efforts by countries across the region to devise the coherent, collective responses that are needed."

However, administration officials, who have often railed against "loopholes" in the U.S. asylum system, have strongly defended the rule, casting it as a much-needed move for the government to deal with the months-long surge of Central America families heading toward the southern border.

Attorney General William Barr — who oversees the country's immigration courts — said the rule was also designed to crack down on "forum shopping by economic migrants," referring to a term used by immigration hardliners to describe the decision-making that they believe migrants engage in. They accuse migrants of preferring to seek asylum in the U.S., rather than in the countries along their journey that might be able to offer them safe haven.