A U.S. judge in San Francisco on Wednesday stopped the Trump administration from enforcing a new rule that would bar almost all asylum applications at the U.S.-Mexico border.

Judge Jon Tigar in the U.S. District Court for 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 travelled through on their way to the United States.

The ruling by Tigar, who was appointed by former president Barack Obama, renders inconsequential a decision that Washington District Judge Timothy Kelly made earlier Wednesday to allow the asylum rule in a different lawsuit, lawyers said.

Kelly was appointed by President Donald Trump, whose administration had been quick to celebrate the Washington decision, saying it would discourage abuse of the asylum process.

Kelly had denied a request for a temporary restraining order on the asylum policy, saying immigrant advocate groups behind the lawsuit did not show that their work would be irreparably harmed if the policy moved forward. The groups sued on behalf of themselves as non-profit groups that offer services to immigrants who would be unable to seek asylum under the new restrictions.

The Washington decision 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.

Key election issue

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 16, 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 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.

Central American migrants wait for food in a pen erected by U.S. Customs and Border Protection to process a surge of migrant families and unaccompanied minors in El Paso, Texas on March 27. Poor living conditions at some detention facilities have sparked massive outrage, and U.S. officials say they are trying to reduce the number of people they detain. (Cedar Attanasio/The Associated Press)

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.

At the northern border, the U.S. and Canada have a "safe third country" agreement that limits people who arrive in one country from seeking asylum in the other. The U.S. has sought to reach the same agreement with Mexico and Guatemala, but Guatemala's high court blocked a possible agreement. Mexico has said no agreement has been decided.

Top U.S. officials say their latest plan would discourage migrants from leaving their countries, which is necessary to reduce the number of people U.S. border agents are detaining. Reports of squalid conditions at some U.S. border detention facilities have sparked mass outrage, and advocates accuse the administration of unnecessarily detaining people seeking asylum and mistreating people in custody.

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.

In November, he struck down a different asylum ban that attempted to block all migrants crossing the border 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.