Handing the Trump administration a setback in its ongoing battle against California’s immigration policies, a federal judge on Thursday upheld the state’s controversial sanctuary laws, setting the stage for another legal fight that could ultimately land in the Supreme Court.

Judge John Mendez denied the Department of Justice’s request for a preliminary injunction blocking Senate Bill 54, the state’s centerpiece sanctuary law limiting law enforcement cooperation with immigration officials, and Assembly Bill 103, which gives state officials the authority to review the conditions of detention facilities that contract with immigration authorities.

But Mendez did block parts of AB 450, the “Immigrant Worker Protection Act,” which fines employers who voluntarily let immigration agents access their workplaces. Under the ruling, employers can still warn their employees of workplace compliance checks, but immigration agents won’t be required to obtain a warrant signed by a judge to enter a workplace.

In his order, Mendez said the state’s decision not to assist federal immigration enforcement isn’t an obstacle for the federal government enforcing immigration law.

“The laws make enforcement more burdensome than it would be if state and local law enforcement provided immigration officers with their assistance,” Mendez, a George W. Bush appointee, wrote. “But refusing to help is not the same as impeding.”

“Standing aside does not equate to standing in the way,” he continued.

An injunction for the sanctuary state law, which the Trump administration has asked for, would have meant that local officials around California could once again work with immigration agents.

Thursday’s ruling “only sets the stage for future appeals,” said Thad Kousser, a UC San Diego political science professor. “This fight’s going to go the full 12 rounds.” California also won in the first court hearings for cases over Trump’s travel ban policy, he pointed out, only for the state’s position to be overruled on appeal by the U.S. Supreme Court.

The decision is the latest notch in the Golden State’s ongoing legal war with the federal government. Attorney General Xavier Becerra has filed more than two dozen lawsuits against the Trump administration since the president took office, and the sanctuary state suit was one of the White House’s ways of firing back.

Immigrant advocates said they saw the ruling as a vindication of California’s resistance. The decision was a defeat for the president’s “hate-filled agenda and escalating abuses of power,” said the ICE out of CA coalition, a statewide alliance of advocacy organizations that advocated for SB 54.

The Department of Justice said it was disappointed that the judge’s ruling didn’t block the sanctuary state law, but applauded the ruling on the employer law.

“California’s political leadership clearly intended to obstruct federal immigration authorities in their state,” DOJ spokesman Devin O’Malley said in a statement. “The preliminary injunction of AB 450 is 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 declined to say whether the department will appeal the ruling on SB54.

The sanctuary state law will be a centerpiece issue in this year’s midterms, and has been galvanizing for Republicans, who have marshaled opposition to it as more than a dozen Southern California municipalities passed ordinances opposing it. The ruling dashes their hopes of getting out of the law, at least for now.

Robin Hvidston, who was among a small group of Trump supporters who rallied at the Sacramento courthouse ahead of the sanctuary hearing last month, said she’s not surprised at the outcome.

“Ultimately, it’s going to end up in the Supreme Court, at which time we’re hoping that they’ll rule on the side of American citizens and find that the state needs to follow federal law,” said Hvidston, executive director of the Claremont-based group, “We the People Rising,” which favors stricter immigration policies.

Still, the lawsuit has helped bring national attention to the sanctuary law and Trump’s attacks on the Golden State. “There’s a political value in suing the state of California, whether or not the federal government wins,” said Hiroshi Motomura, a UCLA law professor.

California’s law does not prevent local authorities from cooperating with ICE in many cases. The state is still required to turn over immigrants who have committed many violent crimes and felonies. “If Democrats want to win on this issue, they have to make people understand what sanctuary state is and who it protects,” Kousser said.

Mendez’s ruling followed a 6½-hour question-and-answer session with attorneys late last month after the Trump White House sued the state in March claiming its laws interfere with the federal government’s power to enforce immigration law. The state argued it can’t be forced to act on immigration law and has vowed to protect its nearly 3 million undocumented immigrants.

Despite Thursday’s favorable decision, Gov. Jerry Brown was in no mood to celebrate the ruling, saying in a statement that more needs to be done to fix a broken immigration system that is splitting the country. “Only Congress can chart the path forward by rising above mindless, partisan divisions and working together to solve this problem, not exacerbate it,” he said.

In his court order, Mendez said the decision was based solely on legal grounds and shouldn’t be interpreted through a political lens. But like Brown, the judge had a message for Congress.

“This court joins the ever-growing chorus of federal judges in urging our elected officials to set aside the partisan and polarizing politics dominating the current immigration debate and work in a cooperative and bipartisan fashion toward drafting and passing legislation that addresses this critical political issue,” he said. “Our nation deserves it. Our Constitution demands it.”