A federal judge ruled Friday that President Donald Trump’s emergency declaration to divert military funding to a southern border wall is unlawful.

In a 33-page ruling, U.S. District Judge David Briones said Trump’s effort to divert more than $6 billion that Congress provided for military projects violates the fiscal 2019 omnibus spending law.

In that measure, Congress provided only $1.375 billion for border barriers that were to be limited to the “Rio Grande Valley Sector” of Texas. Briones noted that none of the funds appropriated by the law could be used for the construction of pedestrian fencing “in any of the five other areas of the border.”

The administration has argued that Trump could use executive authority to respond to a national emergency and divert funding to extend the wall along the U.S.-Mexico border. The wall was one of key promises Trump made during his presidential election. But Briones said Trump couldn’t divert money Congress provided for military construction and counterdrug operations when it would violate a specific statute of the appropriations law, known as the Consolidated Appropriations Act.

“Here we have far more than ‘indicia’ or legislative history establishing Congressional expectations as to how the funds are spent: the plain text of the CAA restricts the amount and location of funding for border barrier construction,” Briones wrote.