A federal court judge in California on Monday permanently blocked United States President Donald Trump’s executive order denying some federal grants to sanctuary cities – cities that limit cooperation with American immigration authorities.

US District Court Judge William Orrick issued a permanent injunction in the suit by San Francisco and Santa Clara counties, who had claimed that the order was unconstitutional, Reuters reported. Orrick had made similar arguments in a ruling that had put a temporary stay on the executive order in April.

“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 said on Monday.

In January, shortly after he took over as president, Trump had issued the order slashing funds to jurisdictions that defy rules that require them to share information with US immigration authorities. The US administration claimed that local authorities endanger public safety by refusing to allow illegal immigrants arrested for crimes from being deported.

“The district court exceeded its authority today when it barred the president from instructing his Cabinet members to enforce existing law,” Department of Justice Spokesperson Devin O’Malley said, according to AP. “The Justice Department will vindicate the president’s lawful authority to direct the executive branch.”