A judge has temporarily blocked an order by United States President Donald Trump that barred asylum for immigrants who enter the country illegally from Mexico — the latest courtroom defeat for Mr Trump on immigration policy.

Key points: Mr Trump's order an "extreme departure" from prior practice, judge said

Mr Trump's order an "extreme departure" from prior practice, judge said Order stated the US would only process those arriving at official entry points

Order stated the US would only process those arriving at official entry points Order came as thousands of migrants in Tijuana tried to gain entry to US

US District Judge Jon Tigar issued a temporary restraining order against the asylum rules, which takes effect immediately and applies nationwide until December 19, when he is set to consider whether to apply a longer-lasting injunction.

Mr Trump cited an overwhelmed immigration system for his recent proclamation that officials would only process asylum claims for migrants who present themselves at an official entry point.

Civil rights groups sued, arguing that Mr Trump's November 9 order violated administrative and immigration law.

Mr Trump's ruling invoked the same authority he used to justify his ban on several Muslim-majority countries. ( Reuters: Ueslei Marcelino )

In his ruling, Judge Tigar — who was nominated for the court by President Barack Obama — said Congress 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," Judge Tigar wrote.

Judge Tigar added that Mr Trump's refugee rule would force people with legitimate asylum claims "to choose between violence at the border, violence at home, or giving up a pathway to refugee status".

The US Department of Justice said it would continue to defend Mr Trump's position, labelling it "absurd" that Judge Tigar allowed civil rights groups to have the ability "to stop the entire Federal Government from acting so that illegal aliens can receive a government benefit to which they are not entitled."

"We look forward to continuing to defend the Executive Branch's legitimate and well-reasoned exercise of its authority to address the crisis at our southern border," the Justice Department said.

Previous Trump administration immigration policies, including measures targeting sanctuary cities and a controversial travel ban, have also been blocked by the courts.

The asylum ruling came as thousands of Central Americans, including a large number of children, are traveling in caravans toward the US border to escape violence and poverty at home.

Sorry, this video has expired Thousands of trekking migrants hope to reach the US as their new home.

Some have already arrived at Tijuana, a Mexican city on the border with California, where many locals are protesting against their arrival, screaming at the migrants to "Get out!"

Rights groups have said immigrants are being forced to wait days or weeks at the border before they can present themselves for asylum, and the administration has been sued for deliberately slowing processing times at official ports.

As of Monday, 107 people had been detained between official crossings have sought asylum since Mr Trump's order went into effect, according to DHS, which oversees Customs and Border Protection.

DHS has said it wants asylum seekers at the southern border to appear at an official border crossing.

But many border crossings such as San Ysidro already have long wait times.

People are often forced to wait in shelters or outdoor camps on the Mexican side, sometimes for weeks.

Mr Trump has ordered thousands of extra troops to the border. ( Reuters: Earnie Grafton )

At a hearing earlier on Monday, American Civil Liberties Union (ACLU) attorney Lee Gelernt said the order clearly conflicted with the Immigration and Nationality Act, which allows any person present in the United States to seek asylum, regardless of how they entered the country.

Mr Gelernt said the ACLU had recently learned Mexican authorities have begun barring unaccompanied minors from applying at US ports of entry.

Mexico's migration institute said in a statement to Reuters that there was "no basis" for the ACLU's claims, noting that there had been no such reports from the United Nations or human rights groups that are monitoring the situation at the border.

Mr Trump sent more than 5,000 soldiers to the 3,100-kilometre frontier with Mexico to harden the border, although critics dismissed the move as a political stunt ahead of congressional midterm elections on November 6.

Reuters/AP