(Reuters) - A federal judge in San Francisco on Wednesday blocked the Trump administration from enforcing a new rule that aimed to bar almost all asylum applications at the U.S.-Mexico border.

U.S. District Judge Jon Tigar in the Northern District of California issued a preliminary injunction blocking the rule, which would require asylum-seekers to first pursue safe haven in a third country they had traveled through on their way to the United States.

The decision makes inconsequential a ruling by Washington D.C. District Judge Timothy Kelly earlier in the day that declined to block the rule in a different lawsuit brought by immigration advocacy groups, lawyers said.

The Trump administration had been quick to celebrate that decision, saying it would discourage abuse of the asylum process.

Following the action by the San Francisco court, the rule will now be suspended pending further proceedings.

“Today’s ruling is an important victory for incredibly vulnerable individuals and families,” said Melissa Crow, an attorney from the Southern Poverty Law Center - one of the groups challenging the ban - in a statement.

The Trump administration has sought to curtail the increasing numbers of mostly Central American migrants arriving at the U.S. -Mexico border after fleeing violence and poverty in countries such as Guatemala, Honduras and El Salvador. It has characterized the vast majority of their asylum claims as bogus.

After the White House announced the rule on July 15, the American Civil Liberties Union and other rights groups sued in California on the grounds it violates U.S. law that welcomes those who come to the United States fleeing persecution at home.

Immigration is shaping up to be a focus of the presidential campaign again in 2020. In the 2016 election, voters rewarded then-candidate Donald Trump’s anti-immigrant rhetoric, sending him to the White House after he promised to build a wall on the U.S.-Mexico border and called for a ban on Muslims entering the United States.

Slideshow ( 11 images )

DANGERS IN MEXICO

Opponents of the new rule contend the United States cannot force migrants to first apply for asylum in another country, such as Mexico or Guatemala, unless Washington first has a “safe third country” agreement with that government. Both Mexico and Guatemala have resisted Trump administration efforts to reach such a deal.

Slideshow ( 11 images )

In an hour-long hearing in California, Tigar said he was struck by the dangers faced by people passing through Mexico, which was significant because the Trump administration argued that country was a safe haven.

“The administrative record about the dangers faced by persons transiting through Mexico and the inadequacy of the asylum system there ... is stunning,” Tigar said from bench.

Tigar in November struck down a different asylum ban that attempted to block all migrants crossing illegally from asking for refuge in the United States.

The Trump administration has issued a rapid-fire series of anti-immigration edicts recently.

Last week, the administration issued another rule to expedite deportations for immigrants who have crossed illegally within the last two years and are caught anywhere in the United States. The rule eliminated a level of judicial review and expanded a program typically applied only along the southern border with Mexico.

Democrats have blasted the policies as cruel, faulting the Trump administration for warehousing migrants in crowded detention facilities along the border and separating immigrant children from the adults they have traveled with.

(This story corrects date rule was announced to July 15 in paragraph 8).