"People will know you can't just smuggle in, hunker down and wait to be legalised.
"Those days are over."
Trump again vowed that Mexico would pay for construction of a "great border wall" between the two countries.
He spoke hours after Mexican President Enrique Pena Nieto told Trump in a face-to-face meeting in Mexico City that Mexico would not pay for it.
"We will build a great wall along the southern border," Trump said. "And Mexico will pay for the wall - 100 per cent. They don't know it yet, but they're going to pay for the wall."
Trump said at a joint news conference with Pena Nieto that he and the Mexican leader did not discuss who would pay for the wall.
Pena Nieto remained silent on the issue at the event, but said later on Twitter he did raise the issue.
"At the beginning of the conversation with Donald Trump I made it clear that Mexico will not pay for the wall," the Mexican President said in a tweet.
Trump used the Phoenix speech to clarify his stance on illegal immigration after prevaricating on the issue last week. He returned to the hardline rhetoric that powered him to the Republican presidential nomination over 16 rivals, heartening those conservatives drawn to Trump by the issue.
Ann Coulter, a conservative activist, tweeted: "I hear Churchill had a nice turn of phrase, but Trump's immigration speech is the most magnificent speech ever given."
Correct The Record, an organisation supporting Democratic nominee Hillary Clinton in the presidential election, slammed Trump. "Tonight confirmed what we knew all along - there is no softening," Correct The Record spokeswoman Elizabeth Shappell said.
Trump's "America First" positions are aimed at rallying middle-class people who feel they have lost jobs to illegal immigrants or to the outsourcing of jobs abroad.
However, he may have put himself at risk of limiting his ability to broaden his base of support to include more Hispanic-Americans and more moderate Republican voters who do not think it is possible or practical to crack down on all illegal immigrants.
In his speech, Trump emphasised that his priority would be to quickly deport those among the undocumented population who have committed serious crimes.
"As with any law enforcement activity, we will set priorities," Trump said. "Anyone who has entered the United States illegally is subject to deportation. That is what it means to have a country."
He said he would form a commission to study which regions or countries he would suspend immigration from, saying Syria and Libya would be high on his list. This would be his way of carrying out his proposed ban on Muslims from some countries without getting into their religious affiliation.
Trump said he would also establish a "deportation task force" to identify criminals subject to deportation, would triple the number of federal deportation officers, and increase the number of border patrol stations.
Trump is trailing Clinton in opinion polls and the New York businessman's aides hoped the trip would make him look presidential and show he was willing to deal head-on with thorny issues such as relations with Mexico.
Pena Nieto said at the joint news conference with Trump in Mexico City that the many millions of Mexicans in the US deserved respect. However, he offered only a mild rebuke of Trump for his rhetoric.
"The Mexican people have felt aggrieved by comments that have been made, but I was sure his interest in building a relationship is genuine," Pena Nieto said.
A few dozen demonstrators gathered beneath a monument to Mexican independence in the centre of the capital to protest against the visit, some holding placards emblazoned with captions such as: "You are not Wall-come" and "Trump and Pena out". Trump has been pilloried in Mexico since he launched his White House campaign last year.
Clinton said yesterday that Trump could not paper over his previous harsh language against Mexico.
"It certainly takes more than trying to make up for more than a year of insults and insinuations by dropping in on our neighbours for a few hours and then flying home again," she told a convention of the American Legion military veterans' group in Cincinnati.
- Reuters