US Republican candidate Donald Trump is to visit Mexico on Wednesday, after repeatedly disparaging the country during his campaign.
Mr Trump tweeted that he was looking forward to meeting President Enrique Pena Nieto, who has invited both him and Democrat Hillary Clinton.
Mr Pena Nieto said dialogue would help “protect Mexicans wherever they are”.
Mr Trump has condemned Mexican migrants during his campaign and vowed to build a wall between the two countries.
He is due to make a major speech on immigration in Arizona later on Wednesday.
The Republican has seen his poll ratings slip since the party conventions last month.
Both nationally and in key states, he trails Mrs Clinton who enjoys particularly strong support among minorities.
The Mexican president said he had invited both candidates for talks and would meet Trump on Wednesday.
“I believe in dialogue to protect Mexican interests in the world and, principally, to protect Mexicans wherever they are,” he said.
Analysis – BBC North America Reporter Anthony Zurcher
Mr Trump going to Mexico is a bold move. It shows he is willing to confront a nation he has mocked in the past. It may make him – dare I say? – look statesmanlike. And if Pena Nieto slams him afterwards, it could end up working to Mr Trump’s benefit.
There is no better way to get conservatives to rally around a candidacy than to have a foreign leader cast aspersions on the nominee.
One risk is that Mr Trump might say or do something controversial while there, although this likely will be a very tightly controlled meeting.
Another is that Mr Trump’s base, the voters who cheered as he called undocumented Mexican immigrants “rapists” and “drug dealers”, will consider this visit consorting with the enemy.
The stakes were already considerable for Mr Trump’s immigration speech on Wednesday night. They just got higher.
Mr Pena Nieto’s office said the two men will meet in private. Mr Pena Nieto has been sharply critical of Mr Trump’s anti-immigration stance and insistence that Mexico would pay for a border wall.
Mr Trump has threatened to stop cash sent home by Mexicans based in the US until the country pays for the wall.
BBC Mexico Correspondent Katy Watson says the prospect has worried many Mexicans who rely on remittances from their families who live in the US.
Mr Trump blames Mexico for the disappearance of jobs from the US, with companies choosing to locate south of the border to take advantage of cheaper labour costs.
Mexico is “ripping off the US more than almost any other nation”, he said in February last year.
In June he expressed anger after a leading golf tournament was moved from one of his courses to Mexico, accusing the PGA Tour of putting “profit ahead of thousands of American jobs”.
Sign up for Ghana Star News to receive daily email alerts of breaking news in Ghana. GhanaStar.com is your source for all Ghana News. Get the latest Ghana news, breaking news, sports, politics, entertainment and more about Ghana, Africa and beyond.