A US judge on Tuesday 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.The ruling from US District Judge William Orrick III in San Francisco said Trump's January 25 order targeted broad categories of federal funding for sanctuary governments and that plaintiff challenging the order were likely to succeed in proving it unconstitutional.The Republican president's moves on immigration have galvanised legal advocacy groups, along with Democratic city and state governments, to oppose them in court. The administration suffered an earlier defeat when two federal judges suspended executive orders restricting travel from several Muslim-majority countries. The government has appealed those decisions.Reince Priebus, Trump's White House chief of staff, told reporters the administration was taking action to appeal the ruling, adding, "The idea that an agency can't put in some reasonable restrictions on how some of these monies are spent is something that will be overturned eventually.""It's the 9th Circuit going bananas," Priebus said, referring to the West Coast judicial district where the judge ruled. "We'll win at the Supreme Court level at some point."A formal White House statement on the ruling was withering in its criticism of Orrick, saying "an unelected judge unilaterally rewrote immigration policy for our nation" and handed "a gift to the criminal gang and cartel element in our country.""This case is yet one more example of egregious overreach by a single, unelected district judge," the White House said.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.Sanctuary cities generally offer safe harbour to illegal immigrants and often do not use municipal funds or resources to advance the enforcement of federal immigration laws. Dozens of local governments and cities, including New York, Los Angeles and Chicago, have joined the growing "sanctuary" movement.Supporters of the sanctuary policy argue that 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 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.Santa Clara County, which includes the city of San Jose and several smaller Silicon Valley communities, sued in February, saying Trump's order was unconstitutional. San Francisco filed a similar lawsuit.The Justice Department threatened last week to cut some funding to California as well as eight cities and counties across the United States.The department singled out Chicago and New York as two cities "crumbling under the weight of illegal immigration and violent crime," even though New York City is experiencing its lowest crime levels in decades and experts say Chicago's recent spike in violent crime has little to do with illegal immigration.Santa Clara County receives about $1.7 billion in federal and federally dependent funds annually, about 35 per cent of its total revenues. The county argued it was owed millions of dollars of federal funding every day and that its budgetary planning process had been thrown into disarray by the order.The Justice Department said the counties had taken an overly broad interpretation of the president's order, which it said would affect only Justice Department and Homeland Security funds, a fraction of the grant money received by the counties.In his ruling, 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," Orrick wrote.The judge cited comments from 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," Orrick wrote.Dave Cortese, president of the Santa Clara County Board of Supervisors, said in a statement, "The politics of fear emanating from the Trump White House has just suffered a major setback."