The GOP nominee said he did not discuss who would pay for the wall.
Donald Trump also called Mexicans “amazing” and “spectacular” people, in contrast to earlier comments branding Mexican migrants “rapists” and “murderers”.
President Pena Nieto said Mexicans had been hurt but he respected that Donald Trump genuinely wanted to build relations.
Donald Trump will later fly to Phoenix, Arizona, to deliver a key speech on measures to tackle illegal immigration.
He has seen his poll ratings slip since the GOP conventions last month.
Both nationally and in key states, Donald Trump trails Hillary Clinton, who enjoys particularly strong support among minorities.
Donald Trump said his words to Enrique Pena Nieto had been strong and straightforward.
He tried to put behind him his previous comments on Mexicans by saying those in the US had made a “great contribution”.
“I have a great feeling for Mexicans. They are amazing people,” he said.
Donald Trump said he had employed many Mexicans and that they were “beyond reproach, spectacular people with strong values of faith and community”.
He said: “We recognize and respect the right of either country to build a physical barrier or wall on any of its borders.”
But he said there was no discussion on who would pay for the wall.
Donald Trump had earlier threatened to stop cash earned by Mexicans based in the US being sent home until the country paid for it to be built.
He concluded by saying he was honored by President Pena Nieto’s invitation to visit, adding: “I call you a friend.”
Enrique Pena Nieto accepted there were border challenges but pointed out the massive contribution Mexicans have made to the US, and that “six million jobs rely on exports to Mexico”.
He said: “My priority is to protect Mexicans wherever they may be. That is my responsibility. Mexicans in the US are honest people, hard-working people who respect their families, their community and the law. They deserve everybody’s respect.”
President Pena Nieto has invited both candidates to visit Mexico, but has faced criticism at home over Donald Trump.
Former Mexican President Vicente Fox earlier told CNN: “We don’t like him. We don’t want him. We reject his visit.”
Former First Lady Margarita Zavala also tweeted: “We Mexicans have dignity, and we reject your hate speech.”
At least two demonstrations have been planned in Mexico City.
Hillary Clinton’s campaign has not yet said if she will travel to Mexico.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…