A federal district court in California on Tuesday blocked the Trump administration from enforcing part of a January executive order to defund “sanctuary cities,” ruling that the directive likely exceeded federal law and unfairly targeted those jurisdictions.

“Federal funding that bears no meaningful relationship to immigration enforcement cannot be threatened merely because a jurisdiction chooses an immigration-enforcement strategy of which the president disapproves,” federal judge William Orrick wrote.

The preliminary injunction blocks the federal government from enforcing Section 9(a) of the executive order nationwide while legal proceedings continue. That section authorized the attorney general to “take appropriate enforcement action” against “sanctuary jurisdictions” that “willfully refuse to comply” with Section 1373, a provision in federal immigration law that bars local jurisdictions from refusing to provide immigration-status information to federal agents.

Orrick determined, however, that Section 9(a)’s broad language, coupled with the new restrictions, likely went beyond what was authorized by federal law. “The order’s attempt to place new conditions on federal funds is an improper attempt to wield Congress’s exclusive spending power and is a violation of the Constitution’s separation-of-powers principles,” he concluded.

Tuesday’s judicial rebuke is also a blow to President Trump’s defense of his administration as it nears the 100-day mark on Saturday. With no major legislative accomplishments to offer the public, the White House has instead pointed to the flurry of executive orders signed by Trump as evidence of his success. This particular order, signed by Trump five days after taking office on January 20, aimed to fulfill his campaign pledges to crack down on illegal immigration and those sanctuary cities, a catch-all term for jurisdictions that don’t cooperate with federal immigration agencies.

Santa Clara County and the city of San Francisco sued the Trump administration soon thereafter, alleging that the order went beyond what Section 1373 authorized. The jurisdictions also argued the new defunding provisions violated the Fifth Amendment’s due-process protections and the Tenth Amendment’s ban on federal commandeering of state powers. At stake for both the city and the county is federal funding, amounting to roughly $1.2 billion of San Francisco’s $9.6 budget and about 35 percent of Santa Clara’s total budget. Orrick noted the executive order “has caused budget uncertainty by threatening to deprive the counties of hundreds of millions of dollars in federal grants that support core services in their jurisdictions.”

In his ruling, Orrick noted the Justice Department tried to defend the executive order during oral arguments by offering a narrow interpretation of it. But the judge indicated he was unconvinced. “The government attempts to read out all of Section 9(a)’s unconstitutional directives to render it an ominous, misleading, and ultimately toothless threat,” he wrote. “It urges that Section 9(a) can be saved by reading the defunding provision narrowly and ‘consistent with law,’ so that all it does is direct the attorney general and [the homeland security] secretary to enforce existing grant conditions. But this interpretation is in conflict with the order’s express language and is plainly not what the order says.”

The Justice Department’s woes did not end there. Compounding their difficulties in defending the executive order were a series of public statements by Trump, White House Press Secretary Sean Spicer, and Attorney General Jeff Sessions, which Orrick cited as evidence the federal government intended to broadly enforce the order.

“The president has called it ‘a weapon’ to use against jurisdictions that disagree with his preferred policies of immigration enforcement, and his press secretary has reiterated that the president intends to ensure that ‘counties and other institutions that remain sanctuary cities don’t get federal government funding in compliance with the executive order,’” he wrote. “The attorney general has warned that jurisdictions that do not comply with Section 1373 would suffer ‘withholding grants, termination of grants, and disbarment or ineligibility for future grants,’ and the ‘claw back’ of any funds previously awarded.”

Shortly after the order’s release in January, my colleague Garrett Epps presciently noted a legal irony: Section 9(a)’s broad restrictions for local jurisdictions that defy federal immigration policy appeared to clash with two landmark U.S. Supreme Court rulings, Printz v. United States and National Federation of Independent v. Sebelius. Taken together, the two decisions constrain the federal government’s power to coerce or compel state and local governments. Both rulings, Garrett pointed out, were also major victories for the conservative legal movement.

Orrick cited both rulings to justify blocking the order’s enforcement on federalism grounds. “The executive order attempts to use coercive methods to circumvent the Tenth Amendment’s direct prohibition against conscription,” he wrote. “While the federal government may incentivize states to adopt federal programs voluntarily, it cannot use means that are so coercive as to compel their compliance.” He also criticized the absence of a mechanism for local jurisdictions to challenge or appeal the loss of federal funding, concluding that the “complete lack of process violates the Fifth Amendment’s due-process requirements.”

Local officials in both jurisdictions praised the ruling. “We’re fighting for the United States Constitution and we succeeded after the Trump administration tried to do an end run around it,” Santa Clara County Supervisor Cindy Chavez said in a statement. Further north, San Francisco City Attorney Dennis Herrera echoed those themes. “Faced with the law, the Trump administration backed down,” he said in a statement. “This is why we have courts—to halt the overreach of a president and an attorney general who either don’t understand the Constitution or chose to ignore it.”

In response to the ruling, the Justice Department noted Orrick limited his injunction to the executive order, not the underlying federal statute. “Accordingly, the department will continue to enforce existing grant conditions and will continue to enforce 8 U.S.C. 1373,” a spokesman said in a statement. “Further, the order does not purport to enjoin the department’s independent legal authority to enforce the requirements of federal law applicable to communities that violate federal immigration law or federal grant conditions.”

The Trump administration’s next legal step would be to appeal Orrick’s ruling to the Ninth Circuit Court of Appeals. It’s a familiar arena for the president: a three-judge panel blocked him from enforcing the first iteration of his controversial travel ban in February, and the entire court will weigh the constitutionality of the second version on May 15.