A federal judge in California on Tuesday temporarily blocked the Trump administration’s efforts to withhold funding from cities that limit their cooperation with federal immigration enforcement, another setback for President Trump in what is shaping up to be a long season of litigation surrounding the clash between the White House and so-called sanctuary cities.

Interactive Feature | Breaking News Emails Sign up to receive an email from The New York Times as soon as important news breaks around the world.

The judge, William H. Orrick of United States District Court for the Northern District of California, issued a nationwide preliminary injunction against the administration, directing it to stop trying to cut off aid to sanctuary jurisdictions. But the order does not prevent the federal government from moving forward on designating certain places as “sanctuaries,” nor does it keep the administration from enforcing conditions for doling out federal money if they already exist, as the Justice Department has already begun to do with some law enforcement grants.

San Francisco and Santa Clara County, which had asked the judge for an injunction, “have a strong interest in avoiding unconstitutional federal enforcement and the significant budget uncertainty that has resulted from the Order’s broad and threatening language,” the judge wrote, referring to Mr. Trump’s January executive order on immigration.