US Republican candidate Donald Trump has arrived in Mexico to meet President Enrique Pena Nieto.
The trip is contentious as during his campaign Mr Trump has branded Mexican migrants "rapists" and "murderers", and vowed to build a wall along the border.
He will face protests on his visit, with ex-President Vicente Fox among those saying he is not welcome.
Mr Trump will later fly to Phoenix, Arizona, to deliver a key speech on measures to tackle illegal immigration.
Mexicans tell Trump: 'You're not welcome!'
Donald Trump's Hispanic voter 'doomsday'
'Me gustan los tacos!': A Spanish phrasebook for Trump's visit
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 tweeted that he was looking forward to meeting President Pena Nieto.
Mr Pena Nieto has invited both US candidates to visit, but has faced criticism at home over Mr Trump.
Vicente Fox told CNN: "We don't like him. We don't want him. We reject his visit."
Former First Lady Margarita Zavala tweeted: "We Mexicans have dignity, and we reject your hate speech."
At least two demonstrations are planned in Mexico City.
But Mr Pena Nieto said: "I believe in dialogue to protect Mexican interests in the world and, principally, to protect Mexicans wherever they are."
Analysis - Anthony Zurcher, BBC North America reporter
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 President 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 probably 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 has previously accused Mr Trump of hurting US-Mexico relations and compared the Republican's rhetoric to that of German Nazi leader Adolf Hitler.
Mr Trump has threatened to stop cash sent home by Mexicans based in the US until the country pays for the wall he intends to build.
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 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.
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".
Mr Trump's campaign manager, Kellyanne Conway, said he would be "very presidential" in the meeting with Mr Pena Nieto.
Running mate Mike Pence said Mr Trump's acceptance of the invitation showed what a "decisive leader" he would be.
Hillary Clinton's campaign has not yet said if she will travel to Mexico.
Mexicans tell Donald Trump: 'You are not welcome'
What Trump has said about Mexico
"They're bringing drugs, they're bringing crime, they're rapists" - May 2015
Mexico is "ripping off the US more than almost any other nation" - February 2015
"Mexico continues to make billions on not only our bad trade deals but also relies heavily on the billions of dollars in remittances sent from illegal immigrants in the United States" - from his immigration plan
...and what Mexico has said about Trump
President Pena Nieto spoke out against Mr Trump's "strident rhetoric" in March, adding: "That's how Mussolini got in, that's how Hitler got in, they took advantage of a situation, a problem perhaps, which humanity was going through at the time, after an economic crisis."
His predecessor, Felipe Calderon, insisted: "Mexican people, we are not going to pay any single cent for such a stupid wall."
After Mr Trump vowed to reclaim all remittances derived from illegal wages, Mr Calderon's predecessor Vicente Fox, told the BBC: "Is Trump going to steal the money? How can any human being think like that? It's incredible."