SAN FRANCISCO (AP) — President Donald Trump's executive order to cut funding from sanctuary cities that limit cooperation with U.S. immigration authorities faced a big setback when a federal judge ruled it was unconstitutional.

But the legal fight over so-called sanctuary cities is far from over. Here's a look at Monday's ruling and what other battles loom:

WHAT DID THE JUDGE SAY?

U.S. District Judge William Orrick rejected the administration's argument that the executive order applies only to a relatively small pot of money, saying the president himself had called it a "weapon" to use against jurisdictions that disagree with his immigration enforcement preferences.

The judge said that under the U.S. Constitution, Trump cannot set new conditions on spending approved by Congress.

The U.S. Department of Justice responded in a statement that Orrick had exceeded his power. The Trump administration says sanctuary cities allow dangerous criminals back on the street.

San Francisco — one of two California counties that sued to block the executive order — says turning local police into immigration officers erodes trust that is needed to get people to report crime.

WHAT DOES THE RULING MEAN?

The judge blocked the executive order temporarily in April, and Monday's ruling made it permanent. It applies nationwide.

The Trump administration already has appealed the judge's temporary halt on the policy. It is pending before the 9th U.S. Circuit Court of Appeals, which could overrule Orrick.

The Justice Department said it would "vindicate the president's lawful authority to direct the executive branch."

WHAT OTHER LEGAL FIGHTS REMAIN?

San Francisco, other cities and the state of California also have sued over a separate move by Attorney General Jeff Sessions to withhold specific public safety grants from sanctuary cities unless they implement tougher immigration policies.

A federal judge in Illinois temporarily blocked that move in September in another nationwide injunction. The administration also is appealing that decision, though it is currently on hold.

ARE THERE OTHER ISSUES AT STAKE?

Under a federal immigration law, cities cannot ban officials from reporting people's immigration status to U.S. authorities. San Francisco accused the Trump administration of interpreting the law more broadly to require that cities hold jail inmates for immigration authorities.

The city does not do that and says the existing federal law does not require it.

San Francisco asked Orrick to rule that its immigration policies meet the federal standard. The judge said he would take that issue up in a separate case.