Trump wants the military to build the border wall. It might not be legal.

After months of back-and-forth with Congress, President Donald Trump is expected to soon declare a national emergency in order for the US military to construct the southern border wall he’s promised for years.

But there’s a pretty big problem with that, according to experts — namely, that he has a very weak legal case, and there’s strong political opposition to making that happen.

Set aside the fact that Trump’s own administration doesn’t assess that there is a massive national security problem at the US-Mexico border. Trump believes there is, and he plans to take extraordinary measures to keep asylum seekers out of the country.

William Banks, a national security law expert at Syracuse University, helped me understand what to expect in the days ahead.

It turns out it’s going to be quite the tricky fight for Trump should he decide to actually declare a national emergency solely to get the border wall built.

The key law in question is the appropriately named “Construction authority in the event of a declaration of war or national emergency.” Here’s what it says:

In the event of a declaration of war or the declaration by the President of a national emergency in accordance with the National Emergencies Act that requires use of the armed forces, the Secretary of Defense, without regard to any other provision of law, may undertake military construction projects, and may authorize the Secretaries of the military departments to undertake military construction projects, not otherwise authorized by law that are necessary to support such use of the armed forces. Such projects may be undertaken only within the total amount of funds that have been appropriated for military construction, including funds appropriated for family housing, that have not been obligated.

There are two main takeaways from this.

First, building the wall must require the use of the military. And second, the only money Trump can use is funds that have been earmarked for military construction projects but not yet assigned to specific ones. There’s roughly $21 billion of that money available.

Both of those will likely present big challenges for Trump to quickly overturn.

The legal and political wall between Trump and the wall he wants

On the first part, the Trump administration must make the case that the only way to build a border wall is if the military does it. That’ll be hard to do, since one could easily argue that civilians could erect the structure. Barring a massive foreign invasion, nonmilitary contractors could safely do the work without the threat of widespread violence.

“This isn’t a military project,” Banks told me on Thursday. “This is a civilian project.” After all, US law enforcement — not the military — continuously guards the US-Mexico border. “It’s a real stretch to argue that a border wall administered by Customs and Border Protection requires the use of the armed forces,” he continued.

The second part is also problematic for the White House. Top lawmakers — including Sen. Jim Inhofe (R-OK), the Senate Armed Services Committee chair — don’t want Trump to use defense money for the wall. “I don’t want anything to degrade military construction,” Inhofe told reporters on Tuesday.

Taking that money would also remove funds from other potential construction projects at home and in war zones abroad.

So it’s possible the president could face bipartisan, bicameral opposition to his plan. But, as Banks noted, Trump would almost surely veto any measure to thwart his objective that reaches his desk. And it’s unlikely that the House and the Senate would come up with the requisite two-thirds votes to overturn his decision.

The most likely outcome, then, is that Trump’s expected national emergency declaration immediately becomes a legal challenge.

Lawsuits on behalf of landowners from Texas to California certainly would be filed as the government attempts to take their land to construct the wall. And some attorneys may say that Trump doesn’t have the legal right to use troops in this case, because there’s no national security threat requiring the military’s participation.

Democrats, meanwhile, have already promised a legal challenge.

Banks warns that the scenario that may soon face the nation — a president declaring a national emergency when there isn’t one, just to build a large barrier — has never been tested in the courts. Courts tend to defer to the executive branch on national security matters, though, so perhaps the administration will win in the end. It also helps that the Supreme Court, should it ever hear a case about all this, skews to the right.

But that process would take months, if not years. That means Trump’s supposed quick fix to get a border wall is anything but, and extremely problematic to boot.