While the morons on the curvy couch are happy to write this off as an "Obama judge" ruling against their guy, the reality is that it was Trump's own big mouth that got federal judge Heywood Gilliam ruling to stay the construction of his mythical border wall.
Essentially, Trump has been insistent that money be directed toward the wall since the beginning of his administration. Hell, he even shut down government--twice--to demand funds. But since the Democratic-controlled Congress actually has the power of the purse strings and the ability to allocate the funds, Trump said that he would use "emergency funds" to get his wall built (all the while insisting that the wall was already being built), identifying $8.1 billion from other projects that he would reallocate towards construction.
He hasn't been specific about every project that will have their funds redirected, although two of the sources are expected to be a Department of Defense fund to support anti-drug activities and another for military construction projects. ThinkProgress explains:
Though a federal statute does sometimes permit military construction funds to be reallocated, [Federal Judge Heywood] Gilliam explains, these funds may only be shifted when applied to other “military construction projects,” and Trump’s wall does not qualify. The statute defines such a project as “any construction, development, conversion, or extension of any kind carried out with respect to a military installation . . . or any acquisition of land or construction of a defense access road.” And Trump’s wall simply isn’t a “military installation.”
The most significant part of Gilliam’s opinion, however, is his analysis of whether Trump can divert Defense appropriations to an anti-drug fund, and then claim that the wall will prevent illegal drugs from entering the United States.
Among other things, Gilliam notes, the administration can only invoke this power when it does so because of “unforeseen military requirements,” but there’s nothing about the so-called border emergency that Trump cites to justify his wall that is “unforeseen.” As a presidential candidate, Trump constantly called for a wall along the Mexican border. Fully one year before Trump announced his plans to divert funds to build his wall, the president called for a border wall in a letter accompanying his proposed 2019 budget. The budget itself claims that a wall “is critical to combating the scourge of drug addiction that leads to thousands of unnecessary deaths.”
Trump, in other words, did not reallocate funds because of some unforeseen military necessity that requires him to bypass the ordinary congressional appropriations process. Rather, Trump announced that he saw the need for a border wall many times over the course of the last three years. He personally requested money to build that wall from Congress, and Congress quite explicitly rejected that request.The supposed border emergency was entirely foreseen by Trump. Congress just disagrees with Trump about what to do about it. As Judge Gilliam explains, the law does not permit Trump to divert Defense funding under these circumstances.
So, if Trump had not ranted about his wall over and over and over again, the court may have found his arguments much more compelling. But because Trump and the rest of his administration have little understanding and less respect for the way government works, their plans are foiled. Again.