President Donald Trump was dealt another legal loss when a federal judge ruled against his deployment of military troops to Los Angeles.

U.S. District Judge Charles Breyer found the president's order violated the Posse Comitatus Act, saying he was using the military as a "national police force with the president as its chief," reported CNN.

“The evidence at trial established that Defendants systematically used armed soldiers (whose identity was often obscured by protective armor) and military vehicles to set up protective perimeters and traffic blockades, engage in crowd control, and otherwise demonstrate a military presence in and around Los Angeles," the judge wrote.

Trump ordered 4,000 National Guard and 700 active-duty U.S. Marines to Los Angeles in June to respond to protests against the administration's immigration raids in the city.

Breyer ordered Trump and Hegseth stop using troops there for “arrests, apprehensions, searches, seizures, security patrols, traffic control, crowd control, riot control, evidence collection, interrogation, or acting as informants” — though he delayed imposition of the ruling until Friday to give the administration the chance to appeal.