Mr Trump said he did not discuss who would pay for the wall.
He also called Mexicans “amazing” and “spectacular” people, in contrast to earlier comments branding Mexican migrants “rapists” and “murderers”.
Mr Pena Nieto said Mexicans had been hurt but he respected that Mr Trump genuinely wanted to build relations.
Mr Trump will later fly to Phoenix, Arizona, to deliver a key speech on measures to tackle illegal immigration.
The Republican has seen his poll ratings slip since the party conventions last month.
Both nationally and in key states, he trails Hillary Clinton, who enjoys particularly strong support among minorities.
Mr Trump said his words to Mr 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.
Mr Trump said he had employed many Mexicans and that they were “beyond reproach, spectacular people with strong values of faith and community”.
He went on to list five points he had set out in his talks:
Ending illegal immigration
Securing the border, with the right to build a physical barrier or wall
Dismantling drug cartels and halting the flow of cash and weapons across the border
Improving the North American Free Trade Agreement (Nafta)
Keeping manufacturing wealth in the American hemisphere
Mr Trump said: “We recognise 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.
He 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.
BBC Mexico correspondent Katy Watson says that prospect has worried many Mexicans who rely on remittances from their families who live in the US.
Mr Trump concluded by saying he was honoured by Mr Pena Nieto’s invitation to visit, adding: “I call you a friend.”
Mr 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.”