A federal judge in San Francisco dealt the Trump administration yet another legal blow Tuesday in a ruling that halted President Donald Trump’s plans to withhold federal funding from cities and towns that refuse to detain immigrants for deportation.

Judge William Orrick imposed a nationwide injunction against a Jan. 27 executive order authorizing the Attorney General to withhold federal grant money from so-called sanctuary jurisdictions that do not cooperate with U.S. immigration officials. However, the judge said the government is within its rights to pull back federal grant money that already came with immigration-related strings attached and, his order largely blocked the administration from doing things its lawyers had said in court it would not do.

Orrick called the order “broad” and “vague” and said the plaintiffs, the city of San Francisco and Santa Clara County, were likely to prevail in the case.

In the 49-page ruling, Orrick pointed to discrepancies in the Trump administration’s own interpretation of the executive order. In court, the government’s lawyers suggested cities and towns were overreacting because the federal officials have not yet defined sanctuary cities or moved to withhold any funding from them. The Justice Department essentially acknowledged in court that the order was a restating of existing law.

Orrick called the order broad and vague and said the plaintiffs, the city of San Francisco and Santa Clara County, were likely to succeed on the merits of their lawsuits challenging it.

In the 49-page ruling, Orrick pointed to discrepancies in the Trump administration’s own interpretation of the executive order. In court, the government’s lawyers suggested cities and towns were overreacting to the order since the federal officials have not yet defined what sanctuary cities are or moved to withhold any funding.

But on television and in news conferences, the judge pointed out, the president and Attorney General Jeff Sessions have threatened to sanction cities and towns that do not cooperate with immigration officials, leaving local officials nationwide fearful that they will lose funding for vital services.

“The result of this schizophrenic approach to the Order is that the Counties’ worst fears are not allayed and the Counties reasonably fear enforcement under the Order,” the judge wrote. “The Order’s broad directive and unclear terms, and the President’s and Attorney General’s endorsement of them, has caused substantial confusion and justified fear among states and local jurisdictions that they will lose all federal grant funding at the very least.”

“The threat of the Order and the uncertainty it is causing impermissibly interferes with the Counties’ ability to operate, to provide key services, to plan for the future, and to budget,” he wrote.

Trump argues that sanctuary cities put Americans at risk by refusing to hold immigrants who have been arrested or convicted of serious crimes so that Immigration and Customs Enforcement can take them into custody and deport them.

Sanctuary cities argue that they do not have the legal authority to hold anyone after a judge in their criminal case has ordered them released on bail.

Immigration arrests are for civil violations and are not criminal in nature.