In his speech, Mr. 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 illegal immigrants, saying only that “the appropriate disposition of those individuals” will take place at some future date after the criminals are deported and his border wall is built.

Deporting all illegal immigrants had been his signature political issue for much of the presidential race, but his caustic tone and harsh approach has turned off many Republicans and independents, particularly women. His language was still fiery in Phoenix, yet he also said that the fate of most illegal 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,” Mr. Trump said, using the sort of vague phrasing that he once criticized.

Never had Mr. 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.