A judge in San Francisco on Tuesday temporarily blocked President Trump’s efforts to starve localities of federal funds when they limit their cooperation with immigration enforcement, a stinging rejection of his threats to make so-called sanctuary cities fall in line.

The judge, William H. Orrick of United States District Court, wrote that the president had overstepped his powers with his January executive order on immigration by tying billions of dollars in federal funding to immigration enforcement. Judge Orrick said only Congress could place such conditions on spending.

The ruling, which applies nationwide, was another judicial setback for the Trump administration, which has now seen three immigration orders stopped by federal courts in its first 100 days. And as with the rulings halting his two temporary bans on travel from several predominantly Muslim countries, the president’s own words were used against him.

Though Justice Department lawyers argued in the case that the government did not intend to withhold significant amounts of money, the judge noted that the president and Attorney General Jeff Sessions had suggested the punishment could be far greater.