Yesterday, a Texas federal district court handed a stunning victory to the county of El Paso in a lawsuit against Donald Trump.

The court found that the US president’s February declaration of a state of emergency at the border between Texas and Mexico injured the county’s reputation and exceeded his executive powers, holding that use of funds allocated for other purposes could not legally be used to fund the border wall.

“Defendants’ use of funds to build a border wall violates the Consolidated Appropriations Act (CAA),” the court wrote. Based on rules of statutory construction that dictate how to read laws about specific and general appropriations, Trump’s use of funds allocated for other purposes—such as drug law enforcement and military building—to construct the border wall was illegal, it held, explaining:

The CAA specifically appropriates $1.375 billion for border-wall expenditures and requires those expenditures to be made on “construction…in the Rio Grande Valley Sector” alone. Defendants’ funding plan, by contrast, will transfer $6.1 billion of funds appropriated for other more general purposes, military construction and counter drug activities. Their plan therefore flouts the cardinal principle that a specific statute controls a general one and violates the CAA.

The victory for the county is particularly notable because the case was decided at an early evidentiary stage. The parties didn’t go to trial after a long document discovery process and they didn’t call witnesses. They battled out the matter in documents, with each side saying the case presented no genuine factual dispute and that they were entitled to a ruling based on their briefs and submissions alone because the only question before the court was a legal one. The court agreed that no trial was needed and sided with the county, citing the president’s motion for summary judgment as evidence that there’s no need for further proceedings.

Trump argued that El Paso didn’t even have standing to sue in this case because it wasn’t injured in any way by the appropriations or the border wall emergency declaration. But the court strongly disagreed with the president’s arguments, stating that the county evidently suffered injury to its reputation and economy as a result of Trump’s declaration and actions.

Still, the case isn’t yet closed. The court hasn’t decided what the consequences of its findings will be, giving El Paso and its fellow plaintiffs in the case 10 days to file a proposed injunction to block the illegal funding. And, of course, Trump can still appeal the district court ruling.