SANTA ANA, Calif. (AP) — A California appeals court on Friday ruled that a state law limiting police collaboration with federal immigration agents doesn’t interfere with a charter city’s right to run its own police force.

The decision reverses an Orange County judge’s 2018 ruling that cities that create their own charters, like Huntington Beach, have a greater degree of autonomy.

The seaside city of 200,000 people sued claiming that California’s so-called immigrant sanctuary law interfered with its authority to enforce local laws and regulations.

California Attorney General Xavier Becerra welcomed the ruling.

ADVERTISEMENT

“We’ll continue to do our part to uphold our state’s laws that work to enhance trust between law enforcement and the communities they serve,” he said in a statement.

California enacted the law following President Donald Trump’s crackdown on illegal immigration. It was hailed as a victory by immigrant advocates seeking to encourage immigrants to trust in local police officers and report crime.

But critics decried the law, saying it makes it harder to deport immigrants who commit crimes and leads law enforcement to release them back into communities.

In California, some cities have their own charters and others follow the state’s general law. Huntington Beach argued that cities that create their own charters to have a greater say over local affairs shouldn’t be subject to the law since it relates to local policing.

Michael Gates, Huntington Beach’s city attorney, said he will discuss the ruling with city officials and may consider taking the case to California’s Supreme Court.

He said he wants to fight on behalf of charter cities, otherwise, “the State will eventually literally be able to dictate every aspect of local governance, which would render local governance pointless.”

Jessica Karp Bansal, a senior staff attorney at the American Civil Liberties Union of Southern California, said the ruling underscores that how immigrants are treated is a statewide concern.

“It is a very straightforward question: Is there a public interest the state has in regulating this? And the court is like, of course,” she said.