Donald Trump‘s administration has been blocked from refusing asylum to immigrants who cross the US-Mexico border illegally, after a federal judge issued a temporary restraining order.

The order had been requested by two US civil rights groups, which launch legal action after the president announced restrictions intended to stop caravans of Central Americans from entering the country.

His ban, proposed to remain in place for three months, would potentially make it harder for thousands of people who enter the US to avoid deportation.

It was blocked by district judge Jon Tigar, who issued a temporary restraining order at a court in San Fransciso after hearing objections from the American Civil Liberties Union (ACLU) and the Centre for Constitutional Rights (CCR).

“Individuals are entitled to asylum if they cross between ports of entry,” said Baher Azmy, a lawyer for the CCR. “It couldn’t be clearer.”

The Department of Homeland Security (DHS) says about 70,000 people a year apply for asylum after surrendering to immigration agents, often in the Arizona desert or on the north bank of the Rio Grande river in Texas.

The government has said asylum-seekers at the southern border must present themselves at official border crossing. But many crossings already have lengthy waiting times, with migrants often forced to linger in shelters or outdoor camps in Mexico for weeks.

Around 3,000 Central American migrants in the first of the caravans arrived last week in Tijuana, Mexico, across the border from San Diego, California. US authorities said they expected another 7,000 to follow.

Many are refugees who have travelled for weeks to reach the US-Mexico frontier after fleeing violence and poverty in Honduras, El Salvador and Guatemala.

Migrant caravan reaches Tijuana on US border Show all 30 1 /30 Migrant caravan reaches Tijuana on US border Migrant caravan reaches Tijuana on US border Members of the caravan of Central American migrants climb the border wall in Tijuana, Baja California, Mexico EPA Migrant caravan reaches Tijuana on US border US Border Patrol agents seen through the concertina wire where the border meets the Pacific Ocean AP Migrant caravan reaches Tijuana on US border Central American migrants pray at a temporary shelter in Tijuana AP Migrant caravan reaches Tijuana on US border Darwin, a 12 year old migrant boy from Honduras, looks out from under a tarp while taking refuge at a shelter in Tijuana Reuters Migrant caravan reaches Tijuana on US border Central American migrants line up for a meal at a shelter in Tijuana AP Migrant caravan reaches Tijuana on US border Angel, a 13-year-old migrant from Honduras looks towards the United States past the border fence in Tijuana Reuters Migrant caravan reaches Tijuana on US border Members of the LGBTQ community -who split from a caravan of Central American migrants heading to the US- arrive at the Diversidad Migrante (Migrant Diversity) NGO headquarters, which they will use as shelter, in Tijuana AFP/Getty Migrant caravan reaches Tijuana on US border US military personell install barbed wire fences to stop the passage of Central American migrants EPA Migrant caravan reaches Tijuana on US border Young Honduran migrant Daniel Gamez waits with his family in a line for a meal after arriving with the Central America migrant caravan in Tijuana AP Migrant caravan reaches Tijuana on US border Two women, one carrying a child, walk north after crossing illegally into the United States as a Border Patrol agent moves in to detain them AP Migrant caravan reaches Tijuana on US border epa07165763 People who are part of the first migrant caravan from Honduras start arriving at the border, in Tijuana, Mexico, 14 November 2018. The first migrant caravan advances through the northwest of Mexico as the US has reinforced its military presence at the border. EPA/Joebeth Terriquez Joebeth Terriquez EPA Migrant caravan reaches Tijuana on US border A child looks out the window of a bus upon its arrival at a temporary shelter in Tijuana AFP/Getty Migrant caravan reaches Tijuana on US border Migrants from Honduras dry their clothes in the sand after washing off in the Pacific Ocean AP Migrant caravan reaches Tijuana on US border Central American migrants at a temporary shelter near the US-Mexico border AFP/Getty Migrant caravan reaches Tijuana on US border US police agents stand guard near the US-Mexico border fence AFP/Getty Migrant caravan reaches Tijuana on US border A migrant, who claimed not to be part of the Central American migrant caravan walks on the US-Mexico border fence AFP/Getty Migrant caravan reaches Tijuana on US border Eldin, a migrant man from Honduras, awakes next to his seven year old son Jose while taking refuge at a shelter in Tijuana Reuters Migrant caravan reaches Tijuana on US border Migrants line up for food at a shelter AFP/Getty Migrant caravan reaches Tijuana on US border A man installs concertina wire on top of the border structure on the US side AP Migrant caravan reaches Tijuana on US border Central American migrants sit on an overlook in Tijuana AP Migrant caravan reaches Tijuana on US border A migrant, who is part of a caravan traveling en route to the United States, shouts as he waits to receive food in a shelter in Tijuana REUTERS Migrant caravan reaches Tijuana on US border A man tries to get over a border structure topped with concertina wire AP Migrant caravan reaches Tijuana on US border People who are part of the Central American migrants caravan arrive at a shelter EPA Migrant caravan reaches Tijuana on US border A Central American migrant moving towards the United States in hopes of a better life, is pictured next to the U.S. border fence in Playas de Tijuana, Mexico, on November 13, 2018. - US Defence Secretary Jim Mattis said Tuesday he will visit the US-Mexico border, where thousands of active-duty soldiers have been deployed to help border police prepare for the arrival of a "caravan" of migrants. (Photo by Guillermo Arias / AFP)GUILLERMO ARIAS/AFP/Getty Images GUILLERMO ARIAS AFP/Getty Migrant caravan reaches Tijuana on US border epa07174393 Members of the Central American migrant caravan remain at a shelter in the city of Tijuana in Baja California, Mexico, 18 November 2018. The 5,000 member migrant caravan that entered Mexico on 19 October that stopped this week in the city of Tijuana, bordering the US, are expected to meet in this city on the next day to make a decision about their future, according to local authorities. EPA/JOEBETH TERRIQUEZ JOEBETH TERRIQUEZ EPA Migrant caravan reaches Tijuana on US border Migrants pray at a temporary shelter in Tijuana AP Migrant caravan reaches Tijuana on US border Migrants shower outside a temporary migrant shelter next to the Us-Mexico border fence Getty Images Migrant caravan reaches Tijuana on US border US Border Patrol agents, left, speak with two Central American migrants as they sit atop the border structure AP Migrant caravan reaches Tijuana on US border A Central American migrant looks on through the US-Mexico border fence AFP/Getty Images Migrant caravan reaches Tijuana on US border A migrant stands next to the border fence REUTERS

US border inspectors at the main crossing in San Diego only process about 100 asylum claims a day, meaning some of the migrants face waiting months in Tijuana if they apply at official crossings.

About 6,000 US troops have been deployed to the border, where the American government has erected concrete barriers and razor-wire fences to keep people out.

Mr Trump has depicted the caravans as a threat to national security and attempted to capitalise on fear of immigration during the run-up to the midterm elections.

The president’s asylum restrictions invoked the same emergency powers used early last year in his travel ban, which mostly targeted Muslims.

According to DHS, which oversees customs and border protections, 107 people had been detained after seeking asylum away from official crossings since the order took effect on 9 November.

Support free-thinking journalism and attend Independent events

ACLU lawyer Lee Gelernt said that some people seeking asylum cross between official ports because “they’re in real danger,” either in their countries of origin or in Mexico.

“We don’t condone people entering between ports of entry, but Congress has made the decision that if they do, they still need to be allowed to apply for asylum,” he said.

The civil rights groups argued the new restrictions violated administrative and immigration law.

In his ruling, Mr Tigar said Congress had clearly mandated that immigrants can apply for asylum regardless of how they entered the country. He called the latest rules an “extreme departure” from prior practice.

“Whatever the scope of the president’s authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden,” wrote the judge, who was nominated to the court by Barack Obama.

The restraining order takes effect immediately and applies nationwide until 19 December, when the judge scheduled a hearing to consider a more long-lasting injunction.