The White House has reacted angrily to news a judge has overturned President Donald Trump's attempt to block so-called sanctuary cities from receiving federal funding.

Sanctuary cities restrict the contact between police and federal immigration authorities, a contact Trump argues is necessary to fight undocumented immigration.

The president was hoping to force sanctuary cities to comply with his executive orders by threatening them with a loss of money – however US District Judge William Orrick III, in San Francisco on Tuesday (25 April) placed an injunction on the order.

A statement issued by White House press secretary Sean Spicer said: "This decision occurred in the same sanctuary city that released a five-time deported illegal immigrant who gunned down innocent Kate Steinle in her father's arms.

"San Francisco, and cities like it, are putting the well-being of criminal aliens before the safety of our citizens, and those city officials who authorised these policies have the blood of dead Americans on their hands.

"This San Francisco judge's erroneous ruling is a gift to the criminal gang and cartel element in our country, empowering the worst kind of human trafficking and sex trafficking and putting thousands of innocent lives at risk."

Judge Orrick said that the language of the executive order made 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 said, adding: "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."

Following the ruling, President Trump took to Twitter to share his thoughts on the matter – issuing a similarly fiery response to that of Sean Spicer. In a series of tweets, Trump said: "First the Ninth Circuit rules against the ban & now it hits again on sanctuary cities-both ridiculous rulings. See you in the Supreme Court!

"Out of our very big country, with many choices, does everyone notice that both the "ban" case and now the "sanctuary" case is brought in the Ninth Circuit, which has a terrible record of being overturned (close to 80%). They used to call this "judge shopping!" Messy system."