The Trump administration and a series of local governments blasted the law as a public safety threat, saying police shouldn't release immigrants convicted of crimes and subject to deportation back into local communities.
The Trump administration sued, but a federal judge in July upheld the state's law. The Orange County city of Huntington Beach sued California and elected officials in the nearby city of Los Alamitos voted to opt out of the law, prompting a separate lawsuit by immigrant advocates.
Michael Gates, the city attorney for Huntington Beach, said Crandall's ruling doesn't just exempt his city from the law but all California cities that make their own charters.
"It violated charter cities' charter authority," Gates said. "Telling our local police what they should be doing, or need to be doing, or not to do as relates to their work in the field by the state is a tremendous overreach."
The Police Department said it continues to cooperate with federal immigration officials.
However, "we have not, and will not, be conducting immigration enforcement in our community," the department said in a statement. "There are times when immigration matters become important to ensuring the safety of our community, but our focus will continue to be overall public safety."
Sameer Ahmed, staff attorney at the American Civil Liberties Union of Southern California, attended Thursday's proceedings in Santa Ana and said he believes the ruling applies solely to Huntington Beach. There was no immediate written decision as Crandall ruled from the bench.
"I don't think this ruling will have, or should have, a very large effect on the applicability of the law going forward," he said.
The state is expected to appeal. Attorney General Xavier Becerra said he will continue to work to ensure the law is upheld across the state.
"Preserving the safety and constitutional rights of all our people is a statewide imperative which cannot be undermined by contrary local rules," he said.
On Friday, Becerra issued new immigration enforcement guidance and model policies that would help "facilities across the state remain accessible to all residents." The guidelines were issued for colleges, universities, libraries, healthcare facilities, courthouses, shelters and labor agencies.