A federal judge on Wednesday blocked President Donald Trump's deployment of National Guard troops in Los Angeles and ordered the troops returned to the state governor's control.

In June, Trump sent thousands of National Guard troops to the California city in the wake of protests over his administration ramping up immigration raids in Los Angeles.

US District Judge Charles Breyer stated the Trump administration had not proven that the city's protests against immigration justified taking federal control of the state's National Guard.

The Trump administration still has control over 300 California National Guard troops six months after they were federalized, Judge Breyer noted.

Breyer also rejected the Trump administration's argument that the courts should not weigh in on a president taking control of state National Guard troops during an emergency, emphasizing a system of checks and balances.

His order will not take effect until December 15, granting the Trump administration time to appeal to a higher court.

“President Trump exercised his lawful authority to deploy National Guard troops to support federal officers and assets following violent riots,” said White House spokeswoman Abigail Jackson.

This year, Trump has dispatched National Guard troops to several cities, including Portland, Oregon, and Washington, D.C., where deployments have faced legal scrutiny.

California Governor Gavin Newsom had previously sought to challenge Trump's orders, arguing the need for troops was diminished as protests waned, prompting a new legal challenge in November.

In a hearing, Trump administration lawyers insisted that troops should remain due to ongoing threats against immigration agents in the area, a claim Breyer appeared to question.

Breyer previously ruled the Trump administration's deployment of the National Guard to Los Angeles this summer was illegal, referring to it as an attempt to create a national police force using state troops.

In the US, all 50 states and several territories have their own National Guard forces, which have become pivotal in the administration’s approach to civil unrest.