Daniel W. Drezner is a professor of international politics at the Fletcher School of Law and Diplomacy at Tufts University and a regular contributor to PostEverything.

Republican presidential candidate Donald Trump speaks to supporters at a rally at the Florida State Fairgrounds in Tampa on Aug. 24. (Octavio Jones/Tampa Bay Times via AP)

So this is happening later today:

The question is why it is happening. As I’ll explain in a moment, there are so many ways this can go wrong that it boggles the mind. Remember Mitt Romney’s disastrous overseas trip in 2012? Scott Walker’s bumbling overseas trip in early 2015? Multiply that by a factor of 10, and that’s how badly this could go.

So why is Trump doing this? There is the compelling logic of Trump’s Razor, but as my Post colleagues Robert Costa, Karen DeYoung, and Joshua Partlow report, Trump didn’t gin up this idea completely on his own:

Trump’s newly installed campaign chief executive, Stephen K. Bannon, played a key role in devising the Wednesday stop while Trump met Sunday with his aides and family at Trump National Golf Club in Bedminster, N.J., according to two people who have been briefed on the campaign’s deliberations.

Bannon, who previously headed the conservative website Breitbart News, made the case to the group that Trump must underscore his populist immigration views in the final weeks of the general-election campaign, perhaps with an audacious gesture.

Peña Nieto’s invitation was brought up, and Bannon said it offered Trump an opening to make headlines and showcase himself as a statesman who could deal directly with Mexico.

So why are Trump and some of his advisers so keen on this gambit? You have to understand three things to explain Trump’s decision:

  1. Whether you look at the polling analysis or the prediction markets, Donald Trump is losing to Hillary Clinton, and it’s not all that close.
  2. There is a chance, albeit not a great one, that Trump can make this trip a political success.
  3. There’s something called prospect theory that explains how people make decisions when they are losing.

To elaborate on that last point: Prospect theory argues that people are not the cool, rational decision-makers that economists like to claim. Rather, relative to what they think the status quo used to be, individuals tend to be more risk-averse if they think they are winning and more risk-loving if they are losing. When individuals are operating in the world of gains, they are more likely to prefer the sure thing to a risky bet that could net them even greater gain. When individuals are operating in the world of losses, however, they will prefer that risky lottery if it would recoup their losses. They will gamble for resurrection.

Republican presidential nominee Donald Trump is slated to meet with Mexican President Enrique Peña Nieto as he tries to clarify his past comments about Mexico and immigration. (Jenny Starrs/The Washington Post)

Relative to how he thought he’d be doing in the general election, Trump is operating in the world of loss. If he manages to go to Mexico City, have a productive meeting with the president of Mexico, generate some good visuals, and then give a tough immigration speech in Arizona, he’ll confound the conventional wisdom that he’d be an unmitigated disaster on the foreign stage. He’d also undercut Clinton’s core argument that Trump is unfit for office. That, plus the fact that this is one of those improvisational, last-minute surprise gambits that someone like Russian President Vladimir Putin would try, makes this the perfect move for Trump at this moment of the campaign.

The problem for Trump and his campaign is that there is a really excellent chance that this will end badly for him. First of all, don’t underestimate the probability of a logistical mix-up. As Costa, DeYoung and Partlow note, “Overseas visits by senior U.S. officials normally require weeks of intricate planning on both sides, as every movement and meeting is plotted. When more security is required, such trips become even more complicated.” There are a lot of things that can go wrong in simply getting Trump in and out of Mexico City without incident or protest. I’m pretty sure Trump will not gain in the polls from images of Mexicans protesting against him.

Second of all, it’s not like Mexican President Enrique Peña Nieto will play the pliant foreign potentate to Trump’s conquering hero. Costa, DeYoung and Partlow wrote, “Peña Nieto himself likened Trump’s rhetoric to that of Adolf Hitler and Benito Mussolini, in a March interview with a Mexican newspaper.” He later backtracked on those comments, but I mean, come on.

Peña Nieto is not terribly popular in Mexico right now in part for reasons I discussed in May. He’s gambling for resurrection as well. I guarantee you that Peña Nieto won’t make himself more popular by being all that nice to a presidential candidate who has mocked his country and would be a disaster if he was elected. He sure as hell ain’t going to agree to pay for a wall.

Finally, this is Donald Trump we are talking about. The odds are excellent that he will not be well-briefed before meeting Peña Nieto and that whatever he says in Arizona later tonight will undercut whatever narrative his campaign wants to spin about today. Trump’s Razor still has some explanatory power.

To sum up: Donald Trump is going to Mexico because he is losing. There is a small probability that this visit could reverse his electoral fortunes. But the odds are not in his favor.