By Bob Egelko

President Trump acted unconstitutionally when he threatened to strip billions of dollars in federal funding from sanctuary cities and counties, like San Francisco and Santa Clara County, that refuse to cooperate fully with immigration officers, a federal judge ruled Monday.

U.S. District Judge William Orrick III of San Francisco had already issued a nationwide injunction in April, blocking enforcement of the executive order that Trump had issued in February and saying it was likely to be found unconstitutional. The Trump administration has appealed that ruling, which remains in effect, and has also sought to backpedal from the broad language of the president's order.

Orrick went further Monday and issued a final ruling saying Trump had committed multiple constitutional violations -- usurping Congress' power over federal spending, seeking to defund programs unrelated to immigration and trying to coerce local governments to change their policies.

"The president has called (his February order) 'a weapon' to use against jurisdictions that disagree with his preferred policies of immigration enforcement," Orrick said.

He said Attorney General Jeff Sessions was not credible in his claims that Trump was actually targeting only a limited number of grants that Congress had expressly tied to compliance with one immigration law.

The injunction that Orrick made permanent Monday has no immediate impact, because the Trump administration is not trying to enforce the president's February order against a broad range of federal funding.

The president's order, "by its plain language, attempts to reach all federal grants," Orrick said. He cited the order's statement that it was intended to make sure that cities and counties "that fail to comply with applicable federal law do not receive federal funds, except as mandated by law," and to deny federal grants to "sanctuary jurisdictions."

The judge also quoted Sessions' warnings that cities, counties and states that do not comply with immigration law, as the administration interpreted it, would suffer "withholding grants, termination of grants, and disbarment or ineligibility for future grants," and would forfeit some funds they had already received.

San Francisco, with an annual budget of $9.6 billion, receives about $1.2 billion a year from the federal government, according to data cited in the ruling. Santa Clara County's reliance on U.S. funds is even greater: The $1.7 billion it received from the federal government in 2015-16 was about 35 percent of its total revenue.

Much of that funding provides "essential services" to local residents in programs unrelated to immigration, Orrick said.

"The president does not have the power to place conditions on federal funds" that Congress has not already imposed, Orrick said. He also said neither the president nor Congress can threaten to withhold funding "in a way that compels local governments to adopt certain policies."

Instead of trying to enforce the February order, the administration is seeking to withhold specific law enforcement grants -- about $1.5 million to San Francisco in the current fiscal year -- from local and state governments that refuse to allow immigration agents to enter their jails or give them advance notice before releasing undocumented immigrants from custody. San Francisco and Santa Clara County are fighting that order in a separate case in Orrick's court, and federal judges in Chicago and Philadelphia have declared the order unenforceable.

San Francisco City Attorney Dennis Herrera still called Monday's ruling "a victory for the American people and the rule of law."

"The only way to stop a bully is to stand up to him," Herrera said in a statement. "That's what San Francisco has done."

He also maintained that the city is complying with federal immigration law, since it allows police to share information with federal agents about the immigration status of anyone in local custody -- the only explicit requirement that Congress has attached to a federal law enforcement grant.

Sessions has argued that the law also requires local governments to notify federal agents before releasing undocumented immigrants, and perhaps even to keep them in custody for up to 48 hours beyond their release date so that immigration agents can pick them up.

Orrick said the 48-hour "detainer" requests are unenforceable. But he declined to rule on whether San Francisco is fully complying with federal law, and said he would address that issue in the separate suit by the two counties.

(c)2017 the San Francisco Chronicle