In a move that has the air of a political stunt, Donald Trump is going to the one country he has consistently vilified since launching his presidential campaign over a year ago: Mexico.

The surprise Wednesday trip will see Mr. Trump fly to Mexico City, meet privately with President Enrique Pena Nieto, and then fly to a campaign rally across the border in Arizona where he will deliver a long-awaited major speech on immigration.

The Mexico trip is bold and unexpected and comes at a moment in the U.S. presidential campaign amidst growing talk Mr. Trump is heading for defeat in November.

Story continues below advertisement

The upside for the Trump campaign is that it will dominate the news cycle and turn the Clinton camp into spectators for a day, as well as showing that Mr. Trump is unafraid of engaging in difficult talks on immigration and free trade with the country's southern neighbour and NAFTA partner.

It is also an unexpected gift to the Trump campaign from Mexico's President. By seizing on Mr. Nieto's invitation from last week, the Trump campaign can argue that no matter what the bombastic and controversial Republican nominee says in public, he can still expect face time with regional leaders and be treated as a statesman.

The downside is Mr. Trump could stumble badly. In 2012, Republican candidate Mitt Romney thought it appropriate to criticize the London Olympics for its lack of preparedness – a move that was widely criticized by British and American politicians and media during his visit to the U.K.

With Mexico, Mr. Trump is stepping into country where he is widely despised for his plan to build a border wall to stop the flow of what he has described as rapists and drug dealers in to the U.S.

Enrique Pena Nieto, Mexico’s president, Justin Trudeau, Canada’s prime minister, and U.S. President Barack Obama arrive at the National Gallery of Canada for the North American Leaders Summit in Ottawa in June.

COLE BURSTON/Bloomberg

Alejandro Hope, a former Mexican intelligence official, likened the Mexican government's decision to host Mr. Trump as World War Two-type "appeasement" of Adolf Hitler.

"For Trump, this makes perfect sense. He polishes his image. What is Pena going to get out of this? Half price on the wall?" he told The Wall Street Journal.

Story continues below advertisement

Mr. Pena's government has struggled to tackle violence and corruption, and his approval rating is at 23 per cent.

The most unpopular Mexican president in two decades will be looking to score some points if he can show that he is standing up to Mr. Trump.

Trump: ‘Our politicians have moved our wealth and factories to Mexico’

From Mexico to Arizona: What's at stake in Trump's immigration speech?

After his meeting with Mexico's President, Mr. Trump will deliver his Arizona speech amid growing talk that the candidate is flip-flopping on key parts of his controversial plan.

The idea of building a U.S.-Mexico border wall still stands.

But what to do about 11 million undocumented residents is up in the air after a week in which Mr. Trump appeared to step away from a key pillar – the creation of a robust deportation force that would round up all illegal immigrants and ship them to their country of origin.

Story continues below advertisement

Millions of U.S. voters were driven to the polls during the Republican state nominating contests, enthralled by Mr. Trump's boldness and straight talk.

With voting day just over two months away, his immigration speech will be closely watched and parsed. Here is a look at how the straight-talking candidate ended up in a muddle – and what could be driving the shifting statements on immigration.

The three pillars of Mr. Trump's plan

1. The Trump wall

Let's start with immovable pillar of the Trump immigration plan: the wall.

Mr. Trump declared his candidacy in June, 2015, with a bang – promising to stop the flow of what he called criminals, rapists and drug dealers. Ever since, "build that wall" has been a regular chant at Trump rallies.

"I will build a great wall, and nobody builds walls better than me, believe me. And I'll build them very inexpensively. I will build a great, great wall on our southern border, and I will make Mexico pay for that wall. Mark my words," said Mr. Trump at his Trump Tower campaign launch.

2. Deporting 11 million people

The other part of his immigration plan is to deport the roughly 11 million undocumented immigrants currently in the country. The plan bucks conventional Washington wisdom that there ought to be a path to legal U.S. status for law-abiding residents who wish to stay in the country.

"We have to get them out. If we have wonderful cases, they can come back in but they have to come back in legally," Mr. Trump told Alabama Republicans in a conference call in September, 2015, vowing to remove all illegal immigrants in two years.

3. Creation of a deportation force

Rounding up 11 million people is no easy feat.

But Mr. Trump has a plan: a robust – and, by all accounts, expensive – deportation force whose job it will be to find and remove illegal immigrants.

"You are going to have a deportation force, and you are going to do it humanely," Mr. Trump told the MSNBC program Morning Joe in November.

The idea was called unrealistic and not serious by his Republican rivals and by Democrats.

The idea of tracking down and deporting 11 million people is absurd, inhumane, and un-American. No, Trump. -H https://t.co/uZyqAWXUdh

Over five consecutive days, the Trump campaign dodged and weaved around questions about the candidate's immigration plan. Here is how it unfolded:

Day 1: A "to be determined" deportation force

The key elements on the Trump immigration plan – a wall, mass deportations and a deportation force – largely stayed in place as Mr. Trump emerged from the nominating contests victorious and turned his attention to the general election.

But that started to change in August – amid floundering poll numbers and campaign team turmoil.

Newly minted campaign manager Kellyanne Conway sparked talk of a Trump flip-flow when she was pressed during an interview with CNN on Aug. 21 on whether a deportation force would be part of Mr. Trump's immigration plan.

Day 2: Getting rid of the "bad ones" first

The day after his campaign manager's comment about a deportation force, Mr. Trump went on Fox News and faced questions about whether he was rethinking his mass-deportation strategy.

Mr. Trump spoke of getting rid "of all the bad ones" first – a reference to gang members.

"They go around killing people and hurting people. And they're going to be out of the country so fast your head will spin," he told host Bill O'Reilly on Aug. 22.

As for the undocumented immigrants not involved in violent criminal activities, Mr. Trump would only say that they would go though a process. They were no longer the primary focus – a remarkable departure from what he has said since launching his campaign.

Mr. Trump appeared to suggest that the process would be similar to the one used by President Barack Obama. In 2014, more than 414,000 people in the U.S. illegally were deported through the courts and with the help of government departments.

Mr. Trump managed to dodge the question of using a deportation force and deflected suggestions that detention centres would be needed to carry out mass deportations.

Day 3: The "softening"

If there are exceptions to the mass-deportation strategy, Mr. Trump did not care to mention them in the 14 months since launching his campaign.

Mr. Trump routinely spoke of 11 million illegal immigrants and the need for their removal as a fixed rule.

But during the a Texas town hall organized by Fox News on Aug. 23, Mr. Trump was asked directly about the countless law-abiding individuals who contribute to American society and have kids in the U.S., and whether they could be accommodated under his immigration plan.

"There could certainly be a softening because we're not looking to hurt people. We want people – we have some great people in this country," he told host Sean Hannity.

The implicit message was that undocumented residents in the U.S. could find a path to legal status without facing deportation.

Day 4: No citizenship, but …

The following day, Mr. Trump presented a new proposal – one that closely resembled plans put forward by his Republican rivals months ago. At the time, Mr. Trump dismissed the ideas as amnesty for illegal immigrants.

During a Fox News interview on Aug. 24, Mr. Trump embraced the idea of offering a path to legal status while rejecting citizenship for illegal immigrants.

"Let me go a step further: They'll pay back taxes, they have to pay taxes, there's no amnesty, as such, there's no amnesty, but we work with them," he said.

It was that last part – "but we work with them" – that caught the attention of many observers.

It appeared to suggest a greater flexibility to creating a path to legal status for millions of undocumented residents in the U.S.

Day 5: Back to the hard-line

The so-called softening did not last long.

In an interview with CNN's Anderson Cooper on Aug. 25, Mr. Trump walked back the idea of offering a path to legal status for millions of U.S. residents.

"There's no path to legalization unless they leave the country," he said.

The focus would be on removing illegal immigrants with criminal records.

As for residents with no connection to criminal activity, they, too, could be rounded up for deportation. "There is a very good chance the answer could be yes," he said.

"We're going to see what happens," he added.

In other words, the idea that families could stay together in the U.S. and go through an in-country process that would give them legal status was off the table.

August 27 speech: Trump vows to crack down on illegal immigrants on Day 1

1:05

What is driving Trump's immigration indecision?

With Labour Day around the corner, the U.S. presidential race is about to kick into high gear. September is when American voters increasingly pay attention and early voting begins.

And with the first of three presidential debates scheduled for Sept. 26, each campaign is looking to lock into a steady rhythm of campaigning, fundraising, TV ad spending and crucial debate preparation.

There is one problem: Poll after poll spells bad news for the Trump campaign. He is languishing in key battleground states. The pressure is on to shake up the campaign.

Mr. Trump's confusing immigration positions could be an effort to shore up and expand support among Trump-weary Republicans.

According to a Pew Research survey in March, 2016, the majority of registered voters, or 59 per cent, oppose a wall along the U.S. border. But looking more closely at the numbers, among Republican registered voters, the support breaks down in favour of the wall.

On the question of what do with millions of undocumented immigrants, the survey showed that a majority of registered voters supported finding a way for residents to stay in the country legally by a margin of 3 to 1.

Among Republican voters, support allowing undocumented immigrants to stay in the country legally was 57 per cent. In others words, Republicans are comfortable with the idea of a border wall, but they are uncomfortable with a national effort to carry out mass deportations.

Mr. Trump's efforts to soften his immigration plan and present a more humane option can be seen as an appeal to a broader Republican electorate. Another factor that could be driving Mr. Trump's decision is economics.

A study by the centre-right policy institute, American Action Forum, estimated that it would cost up to $300-billion (U.S.) to round up and deport 11 million undocumented immigrants.

And it would take 10 times longer than the two years estimated by Mr. Trump.

After the 20-year period, the U.S. would need to spend an additional $315-billion to stop illegal immigrants from re-entering the country, and economic cost of the mass deportations would be a U.S. economy shrinking 5.7 per cent, according to the report released in March, 2016.

This kind of massive government spending – and expansion – is a tough sell on the campaign trail and on the debate stage when the Republican and Democratic rivals face off.

Could Trump soften his stance on the wall?

There already exists an intricate web of scanners, cameras, drones and border guards on the ground trying to stop people from crossing into the U.S. illegally.

But Mr. Trump's vision is not expanding the high-tech "virtual wall."

Instead, it involves building a physical structure along the southern border. That is what he sold to U.S. voters during the Republican nominating contests – and by all accounts, it is what he's offering general election voters.

The cost of building the U.S.-Mexico border wall is another matter, and by some estimates Mr. Trump's figures are on the low end.

The border stretches for about 3,200 kilometres. Mr. Trump has said only about half of the border would require a concrete wall because other sections are protected by geography that make it hard to pass.

There is also the issue of an existing 1,078-kilometre fence which was started during the George W. Bush presidency and cost $2.4-billion. Mr. Trump has not clarified whether his wall will include or replace the fence.

A man planning to cross into the U.S. illegally stands near the dry concrete-lined Tijuana River basin, on the Mexican side of the U.S.-Mexico border in 2008.

GUILLERMO ARIAS/AP

National Guardsmen weld a section of wall being erected along the international border that separates San Luis, Mexico, and San Luis, Arizona, in 2007.

MATT YORK/AP

Mr. Trump's estimate for the wall is between $10-billion and $12-billion. His plan is to get Mexico to pay for it by threatening to block the remittances system that allows U.S. residents to send money to family relations in Mexico. But Mexico has said it will not finance the project or take part.

According to Bernstein Research, which manages investment portfolios and carries our research, the Trump wall stretching along half the border – or about 1,609 kilometres – and at a height of 12 metres could end up costing between $15-billion and $25-billion.

The project would require seven million cubic metres of concrete and an additional 2.4 million tonnes of cement, according to the analysis published in July.

To put those numbers in context, the CN Tower required 40,524 cubic metres of concrete to build. Building the Trump wall would be the equivalent of 175 CN Towers worth of concrete.

There simply would not be enough concrete and cement manufacturing on the U.S. side of the border and "the large quantities of materials required may necessitate procurement from both sides of the border," the report concludes.

In other words, Mexican companies could end profiting from the Trump wall.

Welcome to The Globe and Mail’s comment community. This is a space where subscribers can engage with each other and Globe staff. Non-subscribers can read and sort comments but will not be able to engage with them in any way. Click here to subscribe.

Welcome to The Globe and Mail’s comment community. This is a space where subscribers can engage with each other and Globe staff. Non-subscribers can read and sort comments but will not be able to engage with them in any way. Click here to subscribe.

Welcome to The Globe and Mail’s comment community. This is a space where subscribers can engage with each other and Globe staff.

We aim to create a safe and valuable space for discussion and debate. That means:

All comments will be reviewed by one or more moderators before being posted to the site. This should only take a few moments.

Treat others as you wish to be treated

Criticize ideas, not people

Stay on topic

Avoid the use of toxic and offensive language

Flag bad behaviour

Comments that violate our community guidelines will be removed. Commenters who repeatedly violate community guidelines may be suspended, causing them to temporarily lose their ability to engage with comments.

Due to technical reasons, we have temporarily removed commenting from our articles. We hope to have this fixed soon. Thank you for your patience. If you are looking to give feedback on our new site, please send it along to feedback@globeandmail.com. If you want to write a letter to the editor, please forward to letters@globeandmail.com.