A federal judge on Monday permanent blocked President Donald Trump’s executive order that attempted to cut funding to so-called sanctuary cities, another legal blow to White House efforts to ramp up deportations and curb undocumented immigration.

U.S. District Judge William Orrick in San Francisco called Trump’s January order “unconstitutional on its face” in his ruling, which made permanent his injunction from April. The White House had threatened to cut federal law enforcement grants from cities that fought Trump’s efforts to combat undocumented immigration and said it would publicly shame localities that failed to comply with attempts to increase deportations.

“The counties have demonstrated that the executive order has caused and will cause them constitutional injuries by violating the separation of powers doctrine and depriving them of their Tenth and Fifth Amendment rights,” Orrick wrote.

The city and county of San Francisco and the county of Santa Clara had argued they could lose billions of dollars in federal funds each year. Lawyers for the U.S. Department of Justice said the order would apply to only a few grants and would involve far less money, an argument rejected by Orrick, who said it was written broadly in an attempt “to reach all federal grants.”

San Francisco City Attorney Dennis Herrera, who filed two lawsuits against the Trump administration, called the decision “a victory for the American people” and said the case was “a check on the president’s abuse of power.”

“This executive order was unconstitutional before the ink on it was even dry,” Herrera said in a statement. “This president and his administration have been trying to twist facts, stoke fears and demonize immigrants to score cheap political points. The American people are too smart for that.”

This case is a check on the president’s abuse of power, which is exactly what the framers of the Constitution had in mind. The only way to stop a bully is to stand up to him. That’s what San Francisco has done. — Dennis Herrera (@dennisherrera) November 21, 2017

The term “sanctuary city” has a broad definition but generally refers to jurisdictions that limit compliance with federal immigration authorities, including some that bar local police officers from asking about immigration status or others that may refuse to turn over undocumented immigrants being held in local jails.

Trump’s own words were used against him in Orrick’s ruling, including an instance where the president said he would use the executive order as “a weapon” against jurisdictions that disagreed with his policies.

You can read the entire ruling below.