A federal judge ruled Tuesday that US President Donald Trump violated federal law by deploying military forces to conduct crowd control and arrests in Los Angeles, marking a significant legal rebuke of the administration’s domestic use of armed forces.

In June, the president deployed military personnel to Los Angeles in a bid to quell protests over his administration’s crackdown on immigration. The same month, Governor Gavin Newsom and the State of California sued Trump, alleging he and the US Department of Defense had unlawfully federalized thousands of California National Guard members without following proper statutory procedures requiring gubernatorial consent, in violation of federal law.

In his decision Tuesday, Judge Charles Breyer of the Northern District of California sided with California, finding that Trump’s deployment of federalized National Guard troops and Marines to Los Angeles since June 7 violated the Posse Comitatus Act of 1878, which restricts military forces from enforcing domestic law except where explicitly authorized by the Constitution or Congress.

Since the LA deployment, Trump has initiated a federal takeover of the Washington, DC police force, and has mused about doing the same in other major cities, including Chicago and Baltimore. If Breyer’s opinion is upheld as it inevitably goes up for appeal, it would drastically inhibit Trump’s agenda to provide federal “law and order” on US streets.

Newsom lauded the ruling, saying in a statement:

Today, the court sided with democracy and the Constitution. No president is a king — not even Trump — and no president can trample a state’s power to protect its people. As the court today ruled, Trump is breaking the law by ‘creating a national police force with the President as its chief.’ That’s exactly what we’ve been warning about for months. There is no rampant lawlessness in California, and in fact, crime rates are higher in Republican-led states. Trump’s attempt to use federal troops as his personal police force is illegal, authoritarian, and must be stopped in every courtroom across this country.

Breyer’s ruling enjoined the Trump administration from “deploying, ordering, instructing, training, or using the National Guard currently deployed in California, and any military troops heretofore deployed in California, to execute the laws, including but not limited to engaging in arrests, apprehensions, searches, seizures, security patrols, traffic control, crowd control, riot control, evidence collection, interrogation, or acting as informants, unless and until Defendants satisfy the requirements of a valid constitutional or statutory exception, as defined herein, to the Posse Comitatus Act,” but stayed the injunction until September 12, giving the administration time to appeal.