WASHINGTON (CNN) -- A federal judge on Tuesday blocked the Trump administration from enforcing a threat to take away funds from sanctuary cities -- the latest blow from the federal judiciary to President Donald Trump's immigration agenda.

In a ruling delivered Thursday, Judge William H. Orrick sided with Santa Clara, the city of San San Francisco and other cities, who argued that a threat to take away federal funds from cities that do not cooperate with some federal immigration enforcement could be unconstitutional.

In granting a nationwide injunction, Orrick blocked the government from enforcing a key portion of Trump's January executive order on immigration, which ordered the Department of Homeland Security and Justice Department to block cities who do not cooperate with federal immigration enforcement from receiving federal funds.

While Orrick's ruling does not find the policy unconstitutional, he did find that the counties and cities that challenged the law demonstrated they could face "immediate irreparable harm" if the policy were allowed to be put into place, and that their constitutional challenge could succeed once the case is fully heard.

He did leave the government some wiggle room, saying that his order does not block the government from enforcing conditions on federal grants nor does it block the government from creating a definition of sanctuary jurisdictions -- but the government will not be able to block federal funds from going to those cities as Trump ordered.

"The Counties have demonstrated that they are likely to succeed on the merits of their challenge to Section 9(a) of the Executive Order, that they will suffer irreparable harm absent an injunction, and that the balance of harms and public interest weigh in their favor," Orrick wrote.

Threats to defund sanctuary cities have been a key piece of Trump's immigration agenda in the beginning of his administration, and Attorney General Jeff Sessions sent letters last week to nine cities requiring them to verify they are compliant with a piece of US law mentioned in the executive order as a pre-condition of their receiving law enforcement grants they applied for.

That pre-condition was actually put in place by the Obama administration, and mayors have said that piece of law is something they actually comply with that law, which requires communication of citizenship status of individuals, even if they don't cooperate with other requests from federal immigration law enforcement.

The-CNN-Wire™ & © 2017 Cable News Network, Inc., a Time Warner Company. All rights reserved.