A federal judge halted enforcement of a "troubling" California law protecting illegal immigrants on Thursday, even as he allowed two other so-called "sanctuary state" provisions to remain on the books for now.

The mixed ruling by District Court Judge John Mendez was largely a win for Democrats in the far-left state, where Gov. Jerry Brown has accused the Trump administration of "going to war" by filing the lawsuit that led to Thursday's ruling.

Mendez, an appointee of President George W. Bush, agreed with the Trump administration that California can no longer enforce a law prohibiting employers from allowing immigration officials on their premises unless the officials have a warrant.

Calling that provision a "troubling" restraint that places employers in a "precarious situation," Mendez said the state had overstepped its authority by "impermissibly discriminat[ing] against those who choose to deal with" federal authorities.

The Constitution's Supremacy Clause precludes California from actively interfering with federal immigration authorities, and Mendez said the workplace provision crossed that line.

TRUMP: CALIFORNIA SANCTUARY LAWS HAVE SPARKED A REBELLION

But Mendez refused to block a law requiring the state to review detention facilities where immigrants are held, and another that prevents local law enforcement from providing release dates and personal information on jail inmates.

Those laws, Mendez said, did not rise to the level of being an active impediment to federal officials, even if they indicated the state's unwillingness to voluntarily cooperate with them.

In a statement, Department of Justice spokesman Devin O'Malley disagreed with that assessment.

"California’s political leadership clearly intended to obstruct federal immigration authorities in their state," O'Malley said, even as he called the judge's limited injunction a "major victory for private employers in California who are no longer prevented from cooperating with legitimate enforcement of our nation’s immigration laws."

O'Malley added: "While we are disappointed that California’s other laws designed to protect criminal aliens were not yet halted, the Justice Department will continue to seek out and fight unjust policies that threaten public safety.”

"This is basically going to war against the state of California, the engine of the American economy." — Calif. Gov. Jerry Brown

The U.S. government sued the state in March as part of a broader effort to crack down on sanctuary jurisdictions.

Thursday's decision came on a request by the administration for a preliminary injunction to immediately halt enforcement of all three sanctuary state laws. It is not a final ruling on the legality of the California laws, but in allowing the two laws to remain, Mendez signaled that he would ultimately uphold them.

An interlocutory appeal is possible, but would be unlikely to proceed until Mendez makes a final ruling on the merits of the case.

Multiple city and county councils have voted to join the Trump administration’s lawsuit against the state, or fight the state's policies in other ways.

In May, President Trump praised those local governments for fighting back against their own state. Attorney General Jeff Sessions has accused Democrats in California of pursuing a "radical, open-borders agenda."

"Each of you has bravely resisted California’s deadly and unconstitutional sanctuary state laws," Trump said at a White House roundtable of local officials on the issue. "You’ve gone through a lot, too, although it’s become quite popular what you do."

But California had asked Mendez to dismiss the administration's lawsuit, which Governor Brown has called reckless.

"This is basically going to war against the state of California, the engine of the American economy. It’s not wise, it’s not right, and it will not stand," Brown said earlier this year, after the administration filed suit.

In a statement after Thursday's ruling, Brown highlighted portions of Mendez's opinion that called for a legislative fix to the ongoing illegal immigration debate.

"I agree with Judge Mendez that piecemeal judicial decisions won't solve the nation's immigration challenges," Brown said. "Only Congress can chart the path forward by rising above mindless, partisan divisions and working together to solve this problem, not exacerbate it."

CALIF GOVERNOR BLAMES 'LOW-LIFE' POLITICIANS FOR OPPOSITION TO SANCTUARY LAWS

The three laws, two of which went into effect in January, follow Trump's promises to ramp up deportations. The administration has tried to restrict funding to sanctuary jurisdictions if they refuse to help federal agents detain and deport immigrants.

California, which this year became the second "sanctuary state," has resisted that move. It has filed more than 50 lawsuits against the administration, mostly over immigration and environmental decisions, and notched some significant court victories.

Fox News' Lee Ross and The Associated Press contributed to this report.