A federal district judge issued a permanent injunction on Friday blocking construction of President Donald Trump’s border wall, holding that it was illegal for his administration to spend current funding for that purpose. The U.S. Department of Justice (DOJ) will immediately appeal.

There are several ongoing lawsuits trying to stop the border wall. This case is before Judge Haywood Gilliam for the U.S. District Court for the Northern District of California, who was appointed by Barack Obama. The left-wing Sierra Club brought suit in that court because it is currently one of the most liberal federal trial courts in the nation.

The Trump administration is reprogramming funds from Sections 8005 and 9002 of the National Defense Authorization Act to build the wall and provide security at the U.S.-Mexican border. The Sierra Club argued that the reprogramming of those funds violates federal law.

DOJ argued in court that “plaintiffs fall outside the zone of interests of § 8005 and thus cannot sue to enforce it,” and besides that, that the Defense Department “has satisfied the requirements set forth in § 8005.” Gilliam rejected those arguments.

He also held that § 8005 funds could be used only for “unforeseen military requirements” and that constructing the border wall did not qualify.

The Sierra Club also argued that the use of these military funds under another part of federal law, 10 U.S.C. § 284, is illegal. But since those funds go through the Sections 8005 and 9002 accounts in any event, Gilliam declined to rule separately on the legality of Section 284 funds.

One win for the Trump administration in this case is that Gilliam continued to reject Sierra Club’s claims under the National Environmental Policy Act (NEPA). The left has had high hopes that it could block the wall by arguing that building the wall is illegal because the federal government has not gone through NEPA’s cumbersome and time-consuming requirements, but even Gilliam acknowledged that the Department of Homeland Security had authority to waive those requirements, which the department did.

Finally, although parts of the case are ongoing and therefore normally this case would be stuck in district court for the time being, Gilliam certified his partial summary judgment decision for immediate appeal. As a consequence, the Justice Department will now take the case to the U.S. Court of Appeals for the Ninth Circuit.

The case is Sierra Club v. Trump, No. 4:19-cv-892 in the U.S. District Court for the Northern District of California.

UPDATE: Gilliam also issued a decision granting partial summary judgment and a permanent injunction in a parallel case brought by California Attorney General Xavier Becerra, who has become prolific in litigating against the president. Gilliam’s order in that case addresses the same issues, and is essentially identical to the order in Sierra Club’s case.

The second case is California v. Trump, No. 4:19-cv-872 in the U.S. District Court for the Northern District of California.

Ken Klukowski is senior legal analyst for Breitbart News. Follow him on Twitter @kenklukowski