A US judge has blocked President Donald Trump's executive order that sought to withhold federal funds from so-called sanctuary cities, dealing another legal blow to the administration's efforts to toughen immigration enforcement.

Key points: A Government shutdown threat recedes as Trump backs away from wall demands

A Government shutdown threat recedes as Trump backs away from wall demands A spending bill must pass this week to avoid shutdown, Trump's wall was a deal breaker

A spending bill must pass this week to avoid shutdown, Trump's wall was a deal breaker Trump stresses the wall will be built "soon" though as Democrats vow to keep fighting

Trump stresses the wall will be built "soon" though as Democrats vow to keep fighting The latest developments put another dent into Trump's aggressive immigration plans

Sanctuary cities generally offer safe harbor to illegal immigrants and often do not use municipal funds or resources to advance the enforcement of federal immigration laws.

The ruling from US District Judge William Orrick III in San Francisco said Mr Trump's January 25 order targeted broad categories of federal funding for sanctuary governments and that plaintiffs challenging the order were likely to succeed in proving it unconstitutional.

Dozens of local governments and cities, including New York, Los Angeles and Chicago, have joined the growing "sanctuary" movement.

Meanwhile, the looming threat of a US Government shutdown this weekend has appeared to recede after Mr Trump backed away from a demand that Congress include funding for his planned border wall with Mexico in a spending bill.

The spending bill must pass by the end of the week to avoid a US Government shutdown.

Mr Trump removed a crucial sticking point when he said on Monday evening (local time) he may wait until Republicans begin drafting the budget blueprint for the fiscal year that starts on October 1 to seek funds for the wall.

However, Senate majority Leader Mitch McConnell said it was too soon to talk about such a possibility and that negotiations were still underway to reach a longer-term deal.

But Democrat senator Chuck Schumer said progress had been made with regards to the spending bill now that Mr Trump's wall demands — which could cost upwards of $66 billion — had been put on hold.

"Democrats have been opposed to including the wall in this bill since the beginning of the negotiations." Mr Schumer said.

"There's no plan to make Mexico pay for it as the President promised it would. There's no plan to resolve the eminent domain issues on the border."

The wall will get built, in case there's any question: Trump

Mr Trump's continued moves to clamp down on immigration via policy and executive orders have galvanised legal advocacy groups — along with Democratic city and state governments — to oppose them in court.

Donald Trump's executive order have drawn widespread criticism from rights groups and foreign leaders. ( AP: C M Guerrero, file )

The administration suffered an earlier defeat when two federal judges suspended executive orders restricting travel from several Muslim-majority countries — the Government has since appealed those decisions.

Loading

Responding to the reports Mr Trump would be delaying the building of the wall ahead of Friday's spending talks, the President vowed on Tuesday (local time) the wall will eventually be built, and "soon".

"The wall is going to get built, in case anybody has any question," Mr Trump said at the White House.

"The wall is going to stop drugs, and it's going to stop a lot of people from coming in that shouldn't be here."

But Democrats also vowed to keep fighting against Mr Trump's wall.

"It's not a negotiation. No wall," Mr Schumer said.

Judge says Trump's language degraded 'sanctuary city' order

Sorry, this video has expired Sanctuary cities under threat in Trump era

Responding to the blocking of Mr Trump's recent sanctuary city executive order, the US Justice Department said in a statement it would follow existing federal law with respect to sanctuary jurisdictions, as well as enforce conditions tied to federal grants.

Supporters of the sanctuary policy argue enlisting police cooperation in rounding up immigrants for removal undermines communities' trust in local police, particularly among Latinos.

The Trump administration contends that local authorities endanger public safety when they decline to hand over for deportation illegal immigrants arrested for crimes.

The executive order by Mr Trump, who made cracking down on illegal immigration a cornerstone of his 2016 presidential campaign, directed such funding to be restricted once the Homeland Security Department determines what constitutes a sanctuary city.

In his ruling, Judge Orrick said the language of the order made it clear it sought to withhold funds beyond law enforcement.

"And if there was doubt about the scope of the Order, the President and Attorney-General have erased it with their public comments," Judge Orrick wrote.

The judge cited comments from Mr Trump calling the order "a weapon" to use against jurisdictions that disagree with his immigration policies.

"Federal funding that bears no meaningful relationship to immigration enforcement cannot be threatened merely because a jurisdiction chooses an immigration enforcement strategy of which the President disapproves."

A view of a section of the wall separating Mexico and the United States, in Tijuana. ( Reuters: Edgard Garrido )

ABC/Wires