Trump told a cheering crowd in Arizona that he would secure the border, and left open the possibility that millions of illegal immigrants be deported.
Hours earlier, he met Mexican President Enrique Pena Nieto but said they had not discussed financing the wall.
The president later insisted he had told Mr Trump Mexico would not pay.
There had been speculation that the Republican candidate would back off his plan to deport the estimated 11m undocumented immigrants living in the US.
In his speech in Phoenix, there were conflicting signals about this. He said their fate was not a “core issue” and that deporting “criminal aliens” would be the priority.
“We will treat everyone living or residing in our country with great dignity,” he said.
But later he struck a more uncompromising note when he added: “Anyone who has entered the United States illegally is subject to deportation. That is what it means to have laws.”
In a fiery speech that was at odds with his softer tone in Mexico City, he said he would:
- Create a “special deportation force” focused on removing immigrants arrested (not convicted) for crimes
- Cut off any path to citizenship and insisted those seeking legal status must return to their own countries first
- Introduce “extreme vetting” of immigrants to make sure they adhered to American values
- Protect the interests of African American and Hispanic workers by restricting legal immigration numbers
- Get tough on people who overstay their visas, making them subject to deportation
Attacks on illegal immigrants have been central to Donald Trump’s campaign and key to his popularity with a section of the American public.
But the Republican is trailing Hillary Clinton in the polls and he needs more support from minorities, including the country’s 55 million Hispanics, if he is to have any chance of winning.
For a very short time, that problem seemed to explain his trip to Mexico City, to meet the president and preach friendship.The softening of Donald Trump didn’t last long. By the time he got to Phoenix the candidate’s rhetoric had hardened dramatically.
He promised to deport two million “criminal aliens” in his first hour in office; warned that millions more would be “subject to deportation” and re-stated his signature pledge, to build that “beautiful” wall.
This was not the policy pivot that many were expecting – and that many think Mr Trump needs if he is to keep his presidential dream alive.
Mr Trump said it was the right of the US to choose immigrants that “we think are the likeliest to thrive and flourish and love us”.
Elaborating on that idea, he said his “extreme vetting” would involve an ideological test for immigrants applying to live in the US.
“Applicants will be asked for their views about honour killings, about respect for women and gays and minorities, attitudes on radical Islam,” he said.
Mr Trump, a New York hotel developer, stormed to an unlikely victory in the Republican primaries partly due to his tough talking on immigration.
And in Phoenix he vowed to protect the interests of Americans who he said lose out to new arrivals.
“We have to listen to the concerns that working people, our forgotten working people, have over the record pace of immigration and its impact on their jobs, wages, housing, schools, tax bills and general living conditions,” he said.
He accused his Democratic rival Hillary Clinton of wanting to grant amnesty to undocumented immigrants and of advocating “open border” policies.
Reacting to Mr Trump’s visit to Mexico, she said he had “choked” by not asking his hosts to pay for his wall.
Soon after his speech, Politico reported that Jacob Monty, one of Mr Trump’s 23-member National Hispanic Advisory Council, had quit the board, saying: “What I heard today was not realistic and not compassionate.”
Another supporter, Alfonso Aguilar, President of the Latino Partnership for Conservative Principles, also told Politico he may withdraw his backing, later tweeting that he felt “disappointed and misled”.
Mr Trump was not the only one to depart later in the day from the cordiality of the joint press conference in Mexico City.
Amid an outcry that he had invited such an unpopular figure to Mexico, President Pena Nieto said some of Mr Trump’s policies posed grave threats to his country.