Judge tosses out Trump administration's lawsuit against California's sanctuary state law

A federal judge on Monday threw out the Trump administration’s legal effort to overturn California’s immigration laws, marking a major defeat to the administration’s war on sanctuary states.

Judge John Mendez approved California’s motion to dismiss the federal government’s lawsuit related to Senate Bill 54.

The state’s sanctuary law also known as the California Values Act, and Assembly Bill 103 – allows the state attorney general to inspect detention centers, the Sacramento Bee reported.

The sanctuary law, SB 54, which prohibits state and local police agencies from informing federal authorities in cases when illegal immigrants facing deportation are released from detention, sparked rebellion by multiple counties across California seeking to opt out of the measure out fears for safety and argued that the state law is unconstitutional.

SOUTHERN CALIFORNIA TOWN STANDS UP TO STATE, VOTES TO REJECT SANCTUARY LAW       

Attorney General Jeff Sessions sued the state of California earlier this year over the sanctuary state policies, arguing that state lawmakers overreached their authority.

The administration’s lawsuit against a portion of Assembly Bill 450, which mandates companies to inform its staff within 72 hours of any federal requests to inspect employment records, was also rejected by the judge, the Bee reported.

But Mendez ruled that the suit against other parts of the same law – such as fines to employers who don’t reject requests by the federal officials to enter their workplaces without a warrant – is allowed to move forward.

"Today's decision is a victory for our state’s ability to safeguard the privacy, safety, and constitutional rights of all our people."

- California Attorney General Xavier Becerra

"Today's decision is a victory for our state’s ability to safeguard the privacy, safety, and constitutional rights of all our people," California Attorney General Xavier Becerra said in a statement. "Though the Trump administration may continue to attack a state like California and its ability to make its own laws, we will continue to protect our constitutional authority to protect our residents and the rule of law."

State Sen. Kevin de León, who introduced the sanctuary state law, said the judge’s decision was “a stunning defeat in the president's racist war on immigrants.”

“The federal judge's decision not only affirms the constitutionality of the California Values Act, but our firm belief that our state resources should not be used to torment immigrant communities and tear families apart,” he added in a statement to the Bee.

Lukas Mikelionis is a reporter for FoxNews.com. Follow him on Twitter @LukasMikelionis.