Donald Trump made an audacious attempt Wednesday to remake his image on the divisive issue of immigration, shelving his plan to deport 11 million unauthorized people and arguing that a Trump administration and Mexico would secure the border together.

In a spirited bid for undecided U.S. voters to see him anew, Trump swept into Mexico City to make overtures to a nation he had repeatedly denigrated, then flew to Phoenix to outline in his usual bullying tone his latest priorities on immigration.

Yet the juxtaposition of Trump's dual performances was so jarring that his true vision on immigration was hard to discern. He displayed an almost unrecognizable demeanor during his afternoon in Mexico, appearing measured and diplomatic, while hours later he took the stage at his campaign rally and denounced unauthorized immigrants on the whole as a criminally minded and dangerous group that sows terror in communities and commits murders, rapes and other heinous violence.

Trump's mixed messages on whom he would deport and when, and how the government would go about removing people from the country, were further muddled by the incendiary language in the Phoenix speech — a deliberate effort by campaign advisers to draw attention to his criticism of unauthorized immigrants rather than the specifics of his plan.

In his speech, Trump fervently tried to depict himself as an ally of average workers, saying their economic interests were far more important than the needs of undocumented workers. But he left unclear what would happen to those millions of unauthorized immigrants, saying only that "the appropriate disposition of those individuals" will take place after the criminals are deported and his border wall is built.

Deporting all immigrants in the United States illegally had been his signature issue for much of the presidential race, but his caustic tone and harsh approach turned off many Republicans and independents, particularly women. His language was still fiery in Phoenix, yet he also said the fate of most unauthorized immigrants would be handled humanely, and not right away.

"That discussion can only take place in an atmosphere in which illegal immigration is a memory of the past, no longer with us, allowing us to weigh the different options available based on the new circumstances at the time," Trump said, using the sort of vague phrasing he once criticized.

Never had Trump gambled quite like this. Aiming to appear statesmanlike, he traveled to politically hostile territory to meet with a president who might have surprised him with a rebuke, and he also risked support from some conservatives who do not want him cozying up to Mexico or softening his immigration plans.

The trip to Mexico City was not without snags. Standing beside President Enrique Peña Nieto, Trump indicated that he had pulled a punch and chosen not to discuss his campaign promise to compel Mexico to pay for the wall. Yet Peña Nieto saw it somewhat differently, saying later on Twitter that at the start of their meeting, "I made it clear that Mexico will not pay for the wall."

Peña Nieto did not dispute Trump at their news conference, however, and Mexican officials said that the two men did not dwell on the wall and that their meeting was conciliatory. Still, campaign advisers to Hillary Clinton, the Democratic nominee, accused Trump of lying, and the Trump campaign issued a statement saying that the meeting was "not a negotiation" and that "it is unsurprising that they hold two different views on this issue."

In Phoenix, Trump responded to Peña Nieto with the hectoring language that has long been part of his strategy to whip up his crowds.

"Mexico will pay for the wall, believe me — 100 percent — they don't know it yet, but they will pay for the wall," Trump said. "They're great people, and great leaders, but they will pay for the wall."

Trump had billed the Phoenix speech as a major address on immigration, and many Republican leaders and voters had hoped for more clarity about his positions. Trump outlined several steps that he would take to deport criminals and those who had overstayed their visas and end so-called sanctuary cities, while saying that "the one route and only route" for others to obtain legal status would be "to return home and apply for re-entry."

"We will treat everyone living or residing in our country with great dignity — so important," Trump said, noting that the status of most unauthorized immigrants was no longer a "core issue" for him.

Trump also invited a group of Americans to the stage who, one by one, shared the names of relatives who they said had been killed by immigrants in the U.S. illegally. They insisted that only Trump could protect the country by securing its borders and moving swiftly to deport immigrants with criminal records.

Yet for all the fiery language and stagecraft, it was far from clear if Trump's most ardent supporters would stick by him as he moved away from his original deportation-focused policy or if he would win over many undecided voters with his new approach.

Trump went to great lengths to urge voters to view the presidential race as an epochal moment.

"We are in the middle of a jobs crisis, a border crisis and a terrorism crisis," he said. "This election is our last chance to secure the border, stop illegal immigration and reform our laws to make your life better. This is it. We won't get another opportunity — it will be too late."

The whirlwind day started after Trump accepted an invitation from Peña Nieto to meet him at the presidential palace to discuss economic and border concerns. For the most part they managed to sidestep combustible issues and ignore raging hostility from average Mexicans. Trump has called them rapists and drug dealers, and he did not apologize for those remarks during a joint news conference when a reporter pressed him for any regrets.

Instead, as an impassive Peña Nieto looked on, Trump sounded conciliatory themes about working together to improve border security. Gone, at least for this foreign trip, were the threats about U.S. interests and superiority that have defined Trump's candidacy and electrified his supporters.

"I think it was an excellent meeting," Trump said.

Peña Nieto, who pointedly emphasized goals like "mutual respect" and "constructive" relations several times in his remarks, did Trump some favors with his respectful treatment: The Mexican president acknowledged that every country had a "right" to protect its own border and suggested that Trump wanted to move on from his antagonistic remarks of the past.

"The Mexican people felt aggrieved by those comments," Peña Nieto said. "But I am certain that he has a genuine interest in building a relationship that would lead us to provide better conditions to our people."

Trump, who has little experience with foreign policy statecraft or news conferences with heads of state, made no obvious mistakes during his trip to Mexico, nor did he breach any protocol during his public appearance with Peña Nieto on a small stage at the presidential palace. As Peña Nieto made lengthy opening remarks in Spanish, Trump clasped his hands at times and tapped them against his thighs as he nodded slightly at other points as he listened to a woman beside him translate the remarks into English.

Peña Nieto came across as civil and stolid, defending the North American Free Trade Agreement — a frequent target of criticism by Trump — and noting that weak border security also allowed weapons and cash often to flow from the United States to Mexican gangs and drug cartels. But for the most part the president took a position of neutrality, neither chastising Trump nor indicating that he favored one U.S. presidential candidate over another.

Trump, who is known for insisting that only he can fix America's problems, suggested that he wanted Mexico to be a partner on border security.

"I really believe that the president and I will solve those problems," Trump said. "We will get them solved. Illegal immigration is a problem for Mexico as well as for us. Drugs are a tremendous problem from Mexico as well as us. I mean it's not a one-way street."

Trump's unexpected trip to Mexico was timed to steer attention from his significant shifts on immigration policy. He flew to Mexico just hours before he was scheduled to deliver a major speech on immigration after more than a week of mixed signals about his immigration views, which he said were "softening" and then "hardening" in the space of two days last week.

On a more personal level, Trump also wanted to show undecided voters that he had the temperament and self-control of a statesman — qualities that many doubt he has — and also demonstrate that Americans did not need to worry every time he opened his mouth in a foreign country. He also hoped to show that he could acquit himself well on the world stage, something that is a clear strength of Clinton, a former secretary of state, senator and first lady.

Clinton's campaign has described Mr. Trump's trip as ahollow gesture, but it was unclear whether Clinton herself will deliver amore pointed critique of her opponent during his travels.