Republican presidential nominee Donald Trump unveiled a 10-part immigration policy plan during a speech in Phoenix on Aug. 31 after meeting with Mexican President Enrique Peña Nieto earlier in the day. (The Washington Post)

The morning after Donald Trump once again embraced his hard-line immigration posture in a shouted speech, at least four members of his two-week-old Hispanic advisory council said they might not vote for the Republican presidential nominee and warned that his harsh rhetoric would cost him the election.

At meetings Thursday on the 14th floor of Trump Tower in Manhattan, the candidate’s top aides held the opposite view. They thought his tough talk on immigration — combined with a whirlwind trip to Mexico on Wednesday — had, in the words of one adviser, “won him the election.”

“How do you like our poll numbers?” Trump excitedly asked in a brief telephone interview with The Washington Post on Thursday. He rattled off recent surveys that he said show his support has inched up.

For nearly two weeks, Trump has publicly and privately debated how best to describe his immigration positions, especially when it comes to the roughly 11 million illegal immigrants in the country.

He spent days floating a series of possible changes and gauging the reaction, and even visited Mexico for a few hours Wednesday in a bid to appear more presidential. But later that night, he decided to stick with the far-right positions that were key to his success in the Republican primaries and could help him cement the support of white men — one demographic where he beats Democratic rival Hillary Clinton.

The roller-coaster debate — which continued Thursday after a speech the campaign heralded as definitive — centered on Trump’s repeated calls during the primaries to deport all of the undocumented immigrants in the country. He suggested that his declaration applied even if they have lived here for decades, are contributing members of society or have children who are U.S. citizens, although he appeared to back away from his call to immediately deport all of the illegal immigrants living in the United States with a “deportation force.”

But in the end, the debate within the Trump campaign turned out to be about messaging rather than policy.

“He hasn’t changed his position on immigration,” Trump surrogate Katrina Pierson said on CNN last week in remarks that were widely mocked at the time but in hindsight seemed to capture internal thinking. “He’s changed the words that he is saying.”

The public side of the debate took a turn on Aug. 20, when Trump held a hurriedly organized Saturday meeting with a newly formed National Hispanic Advisory Council at Trump Tower. He asked those around the table to share alternatives to mass deportation, signaling that he was willing to change his mind on the issue.

The council urged Trump to focus on how undocumented immigrants contribute to the nation’s economy and abandon his plans to quickly deport millions — a view Trump heard from fellow business owners and wealthy Republican donors over the course of the summer. For several days, the candidate seemed to echo these views, saying in interviews with Fox News Channel that he would be willing to work with those who came here illegally and are living prosperous lives.

At a town hall meeting in Texas, Trump even polled audience members to get their input on the fate of the nation’s undocumented immigrants, using his most flattering language to date.

But some Trump advisers told him that many voters like his stubborn dedication to issues that other politicians won’t touch, and warned that flip-flopping on immigration would make him no different from the career politicians he has accused of being “weak” and beholden to donors.

Republican presidential nominee Donald Trump said that he intends to create a deportation task force for removing violent undocumented immigrants in the U.S. (The Washington Post)

These advisers urged Trump to use tough, nativist language in his immigration speech in Phoenix on Wednesday to create as sharp a contrast as possible with Clinton. They argued that by showing strength and force of leadership, Trump will attract undecided voters.

“We had a serious adult conversation about where we are. The people that won this debate said, ‘Look, this is what got us here, and we can’t abandon it,’ ” one Trump adviser said Thursday, speaking on the condition of anonymity to be candid about the campaign’s internal deliberations. “There were many of us who made input, and it was clear that the hold-the-line people, we had more sway with him. I think the political calculation is, you can’t abandon the base.”

By Thursday of last week, Trump’s tone was noticeably different during an interview with CNN, when he said that any immigrant who wants to become a legal resident would have to leave the country and apply to return — a process that can take many years.

“You have a lot of people being deported” already, he said on CNN, having praised the policies of President Obama and former president George W. Bush in an earlier interview. “We’re going to do that vigorously.”

As Trump’s campaign was debating whether and when he should give an immigration policy speech, the nominee received a three-page invitation from Mexican President Enrique Peña Nieto.

The prospect of a preelection Trump visit alarmed several Mexican cabinet members, but Peña Nieto decided to do it. Advocates for the meeting viewed it not as a chance to raise the president’s sagging approval ratings, but as a political gamble that was important in the long run in case Trump won.

But Trump surprised them by agreeing to come within days. Not all parts of the Mexican government were fully informed about the plan, and the U.S. Embassy was alerted to the visit by the Secret Service, arranging the logistics of his trip.

Trump arrived Wednesday afternoon — hours before he was to give his immigration speech in Phoenix — and met with Peña Nieto for about an hour. Each then gave friendly remarks praising his neighboring nation. Many pundits lauded Trump for seeming willing to work with the leader of a nation that he has insulted so deeply during his campaign.

Hours later, Trump’s tone changed significantly as he gave his formal policy speech — broadly painting many undocumented immigrants as violent criminals and promising that he would quickly deport millions. At least 5 million immigrants would be subject to rapid deportation under Trump’s latest proposals, according to a Post analysis.

“That is all him. Those are his decisions,” a top campaign aide said, speaking on the condition of anonymity to discuss internal talks. “He got very different viewpoints on immigration. But in the end, it was all him. That speech has to be his words, his cadence, his delivery.”

Former New York mayor Rudolph W. Giuliani — who traveled with Trump to Mexico and has been a key figure in the candidate’s discussions on the issue — said the contrasting speeches showed Trump’s range.

“This is what a president has to be able to do,” Giuliani said. “If you’re meeting with a head of state, you’ll act differently than if you were at the Heritage Foundation speaking to scholars or speaking at a rally. That’s why Trump seized on the invitation so quickly. He wanted to show that he could operate on several fronts and speak to different audiences, boldly and regardless of the risk.”

But the harsh tone of the policy speech stunned Jacob Monty, a member of Trump’s Hispanic advisory council and a Houston-based immigration lawyer. Monty has helped Trump raise money and wrote a newspaper column in June headlined, “A Latino’s case for Donald Trump.”

“The speech was just an utter disappointment,” he said in an interview Thursday.

Soon afterward, Monty resigned from the advisory group and posted on Facebook that he will not vote for Trump.

“I don’t want to be a prop like the Mexican president,” Monty said in the interview. “We were out there defending him. And then to be just lied to like that — it doesn’t feel good. It’s not okay.”

Others felt the same way. Ramiro Peña, a Texas pastor, called the advisory council “a scam” in an email to campaign and party leaders, according to Politico. Massey Villarreal, a Houston businessman, deemed the speech “awful” in an interview with NBC Latino. Alfonso Aguilar, a Latino activist, tweeted that he felt “disappointed and misled.”

Even as those defections were unfolding Thursday morning, more than a dozen senior Trump campaign staff members met at Trump Tower to map out their strategy for the rest of the race. The mood in the room was charged and optimistic, with attendees praising Trump’s speech and trip as a jolt to his bid, according to two people familiar with the discussions who spoke on the condition of anonymity to discuss a private meeting.

One Trump ally involved in the talks Thursday described Wednesday’s drama as the “day that won him the election” because of Trump’s reiteration of his conservative views on immigration, which many in his orbit consider crucial to wooing economically frustrated working-class voters.

And in another sign that Trump’s orbit would continue to hold to its combative ethos, longtime conservative operative David N. Bossie was introduced as the new deputy campaign manager. Bossie, previously president of the Citizens United advocacy group, has been a prominent investigator of Clinton controversies for decades.

“A friend of mine for many years,” Trump said, speaking from his office in New York. “Solid. Smart. Loves politics, knows how to win.”

Yet even after his big speech, Trump continued to send mixed signals.

“We’re going to sit back, we’re going to assess the situation, we’re going to make a decision at that time,” he said on Fox News Channel on Thursday night about undocumented immigrants who had not committed other crimes. “I want to see, before we do anything further, I want to see how it shapes up when we have strong, impenetrable borders.”

Joshua Partlow in Mexico City contributed to this report.