WASHINGTON — President Donald Trump had the perfect script written for the unofficial launch of his re-election campaign in El Paso, Texas.

Back on the trail on Monday night — amid a flurry of Democrats entering the 2020 race and with the backdrop of an iconic border crossing — the president was champing at the bit to the tell the story of an extremist rival party that is hostile to border security and of the wall he would build come hell or high water.

But just before he took the stage, the script flipped.

Back in Washington, Trump learned, Congress had just demolished his wall.

A bipartisan group of House and Senate negotiators — no doubt aware of when Trump was set to begin speaking — sent word Monday evening that they had struck a deal to avoid a shutdown and keep the Homeland Security Department and other federal agencies open past Friday. Democrats had quickly dropped a demand to cap the number of undocumented immigrants that federal authorities could detain at length that had been hanging up the talks, and Republicans had agreed to limit new border fencing to 55 miles.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

In other words, no wall.

It was a predictable outcome: When Trump announced last month that he was ending a self-inflicted 35-day partial government shutdown, it was clear he was flying the white flag of surrender from an imaginary watchtower on the unbuilt wall. But the final frame of the president's slow-motion capitulation couldn't have come at a worse moment for him.

He was minutes away from accusing Democrats of risking a second government shutdown over what he says are far-left immigration policies that endanger Americans' personal and financial security. He has said he believes it's a winning issue for him — and a losing one for them — despite the fact that he campaigned on immigration during the midterm elections and Democrats won handily across the country.

But it will be harder for Trump to paint Democrats as radicals — either in Congress or on the presidential campaign trail — after Republicans struck the border-security deal with them. Now, Trump will have to decide whether he wants to stand against both parties in Congress, whether he wants to shut down the government over the wall again or declare a national emergency and whether he thinks he's a good enough salesman to make the case that Democrats are extremists when his position on the wall is the minority one.

Trump was undeterred by the new information on Monday night.

"They said that progress is being made with this committee," he said at the rally. "Just so you know, we're building the wall anyway."

He also continued to say Democrats are for open borders, even as they had just agreed to spend billions of dollars more on border security.

"The Democrat Party has never been more outside the mainstream," he said. "They're becoming the party of socialism, late-term abortion, open borders and crime."

That is to say, logic and the facts weren't the strong suit of his argument.

But it's understandable that Trump — who gave a shoutout to the Alamo during his remarks — didn't want to turn the spectacle of his first big campaign rally of the presidential election season into an acknowledgment that he had just suffered another stinging defeat on the central promise of his last campaign.

By all accounts, including his own, he had been looking forward to this moment. There can be little doubt that, after watching Democrats pile into the presidential race over the last couple of months, Trump had been more than ready to let loose. And, as he said Monday night, it was "more fun" to go to a campaign rally than to deliver his State of the Union address last week.

The next part — the reality of Congress outright rejecting his wall yet again — promises to be a lot less fun.