A federal judge ruled Tuesday that the Trump administration violated federal law in deploying National Guard troops during immigration enforcement operations and related protests in Southern California.

U.S. District Judge Charles Breyer, based in San Francisco, concluded that the administration’s use of troops in Los Angeles contravened legal limits on military involvement in domestic affairs. His order, which takes effect Friday, does not immediately require the withdrawal of all remaining troops.

The ruling came in response to a lawsuit filed by the state of California. State officials argued that the deployment violated the Posse Comitatus Act, which generally prohibits the military from enforcing domestic laws. Attorneys for the federal government countered that the Act did not apply, asserting that the troops were tasked with protecting federal officers rather than carrying out law enforcement duties. They also maintained that the president has the authority to mobilize the Guard under certain federal statutes.

The decision arrives as former President Donald Trump has previously discussed the possibility of National Guard deployments in several large cities, including Chicago, Baltimore, and New York. He had earlier deployed Guard units in Washington, D.C., where the federal government holds direct control.

In California, Trump federalized members of the state’s National Guard and sent them to Los Angeles despite objections from Governor Gavin Newsom and local officials. The administration cited a law allowing the president to call the Guard into federal service in cases of invasion, rebellion, or when necessary to enforce U.S. laws.

Also Read: SSA Chief Data Officer Steps Down Amid Whistleblower Allegations

The broader issue of military involvement in domestic operations has been a point of contention throughout Trump’s tenure, with critics raising concerns over the scope of presidential authority.

Following the ruling, Governor Newsom posted on X that the court had confirmed the deployment was unlawful. The White House did not immediately respond to a request for comment.