President Donald Trump declared a national emergency on Friday in order to build a barrier along the U.S.-Mexico border. If he ultimately gets the wall he wants, it will only be because Democrats who control the House of Representatives let him have it.

Fortunately, the Constitution does not give the president unfettered authority to spend federal funds on his own pet projects. Instead, we have a finely crafted system of checks and balances. Unfortunately, that system of checks and balances doesn’t function when the actors who have the ability to check the president decline to use their power. By voting on Thursday to approve a budget deal without any explicit language barring the president’s end-run maneuver, House Speaker Nancy Pelosi and members of her caucus decided not to exercise their check. Now, they can’t count on the courts to do it for them.

The White House says that Trump plans to use $3.6 billion in military construction money for his wall. He can potentially do that on account of the 1982 Military Construction Codification Act, which says that when the president declares a national emergency “that requires the use of the armed forces,” the defense secretary may use available military construction funds to “undertake military construction projects … not otherwise authorized by law that are necessary to support such use of the armed forces.” The Trump administration will argue that the wall is necessary to support the 6,000 active-duty troops now at the southern border. (The administration also plans to supplement the military construction money with smaller amounts from other sources that aren’t linked to the announcement of a national emergency.)

Here’s what happens next: The 1976 National Emergencies Act allows Congress to override the president’s emergency declaration, and if the House passes a resolution to that effect, the Senate would have to put it up for a vote within 18 days. It’s not implausible that some Republican senators—including those like Susan Collins of Maine and Cory Gardner of Colorado, who are gearing up for 2020 re-election battles in purple states, as well as Republicans whose home states are affected by the diversion of Army Corps construction money—might join the Democratic minority to pass the resolution of disapproval in the upper chamber. (Defense hawks who object to the diversion of military construction funds might join in.) But the president could veto any congressional resolution, and it’s unlikely that opponents of the wall could cobble together the two-thirds majorities in both houses that they would need for a veto override.

So that leaves us with our last best hope: the courts. Alas, the legal challenge to the president’s exercise of his emergency authority is far from a slam dunk.

First, it’s not clear that anybody could successfully sue to overturn the president’s emergency declaration. The typical way to challenge “arbitrary and capricious” actions by the federal government is to sue under the Administrative Procedure Act, but the Supreme Court held in a 1992 case that the Administrative Procedure Act doesn’t apply to actions taken by the president himself.

The House of Representatives might nonetheless try to sue in its institutional capacity on the ground that Trump, by spending funds that the legislative branch didn’t grant him, has trammeled on Congress’ power of the purse. This suit wouldn’t be based on the Administrative Procedure Act or any other specific statute but instead on general separation-of-powers principles. This might work, but there are significant hurdles along the House’s path.

The first is the doctrine of standing. The Supreme Court held in a 2015 case that “legislators whose votes would have been sufficient to defeat … a specific legislative Act have standing to sue if that legislative action goes into effect … on the ground that their votes have been completely nullified.” The Democratic-led House would argue that the president’s decision to fund the border wall is essentially a “legislative act” beyond his authority, and thereby “completely nullified” House members’ votes. But not all of the justices are on board with this “legislative standing” doctrine. In one of his last opinions, Justice Antonin Scalia said that “[d]isputes between governmental branches … regarding the allocation of political power” are not “cases” or “controversies” that the courts can resolve. Justice Clarence Thomas agreed. Justices Neil Gorsuch and Brett Kavanaugh, who joined the court after 2015, might well adopt the same view. If so, then the House Democrats would start out with three votes at the high court against them.

In any event, a win on “standing” merely gets the House into court; it doesn’t resolve the main issue. On the merits, a court might say that the National Emergencies Act provides a specific mechanism for lawmakers to override the president’s declaration and that the House’s lawsuit amounts to an illegitimate end-run around that mechanism. Or a court might defer to the president’s determination that an emergency exists, adding that if Congress didn’t want the administration to have the power to redirect military construction funds, it shouldn’t have ceded that authority. To be clear, I think that the House could mount a strong case, but I’m not at all confident that the federal courts—and especially the current Supreme Court—will agree.

Even if the courts side with the president against the House, we will still likely see a raft of piecemeal challenges to different parts of the wall from private landowners, environmentalist groups, and others. Some of these efforts might succeed in temporarily or permanently blocking portions of the barrier. But there was a much more straightforward way for House Democrats to fully block the president from building his wall, and they passed up that opportunity Thursday night.

The legal challenge to the president’s exercise of his emergency authority is far from a slam dunk.

If the House had added a single sentence to the government spending bill—saying, in effect, that “no additional funds authorized or appropriated under any other law may be redirected to the building of a border wall”—then the legal landscape would now look quite different. It is entirely within Congress’ power to take away any funds that the president might access under the Military Construction Codification Act, or any other statute, for his border barrier. To be sure, the Senate might not have passed such a bill, and even if it did, Trump might have vetoed it. But at least the House Democrats had leverage—their votes were needed to avert a government shutdown. Now, they have effectively relinquished that leverage until the current spending legislation expires at the end of September.

So why did the House pass the spending bill Thursday night with full knowledge of the president’s next move? Perhaps Democratic leaders feared blowback from voters for allowing another shutdown. Perhaps they decided that—as terrible as the border wall and usurpation of their appropriations authority might be—it’s not a sufficiently significant issue to justify a partial halt to government operations again. Perhaps they thought that the courts would do what the House Democrats declined to do themselves: confront the president’s bald assertion of executive authority head-on.

Any or all of those calculations might have been right. But they each entail enormous risks. If the president prevails in his bid to build a wall, the political bounce might buoy his chances for re-election in 2020. Another government shutdown would be bad, but a total breakdown in constraints on presidential power will be even worse. And while the judiciary is the last line of defense against executive overreach, that shouldn’t lead lawmakers to lose sight of the fact that they are the first.

Agree or disagree with the House Democrats’ decision, we should all be clear about what that choice entailed. By voting to pass a spending bill that lacked any safeguard against the use of emergency powers for construction at the border, House Democrats made it much more likely that the president’s emergency gambit would succeed. Congress’ power of the purse is arguably the most significant barrier to an executive unbound. By letting that barrier fall, House Democrats might well have allowed Trump’s wall to rise.