A federal judge in California on Monday permanently blocked President Trump’s executive order to withhold federal funding from sanctuary cities that do not cooperate with U.S. immigration authorities.

U.S. District Court Judge William Orrick ruled that the White House does not have the authority to impose new conditions on spending already approved by Congress.

“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,” the judge wrote in his order.

The latest decision is in line with the argument Orrick made in April that temporarily halted the administration’s attempt to crack down on sanctuary cities, prompting an appeal.

Trump has campaigned on ending sanctuary cities. He issued an executive order that called on cutting federal funds from cities as a penalty for shielding illegal immigrants.

"The District Court exceeded its authority today when it barred the President from instructing his cabinet members to enforce existing law," a Department of Justice spokesman said in a statement. "The Justice Department will vindicate the President's lawful authority to direct the executive branch."

The judge’s ruling on Monday came after two California counties, San Francisco and Santa Clara, filed lawsuits against the Trump administration.

"President Trump might be able to tweet whatever comes to mind, but he can't grant himself new authority because he feels like it," San Francisco City Attorney Dennis Herrera said in a statement, adding that the ruling was “a victory for the American people and the rule of law.”

A DOJ lawyer argued in April that the initiative would only apply to a few federal grants, barely affecting the funding in the two counties that filed the lawsuits.

But the judge disagreed, saying the order was written vaguely and could “reach all federal grants” – potentially leading to cutbacks of millions of dollars to Santa Clara and San Francisco.

The Associated Press contributed to this report.

Lukas Mikelionis is a reporter for FoxNews.com. Follow him on Twitter @LukasMikelionis.