Donald Trump said Wednesday that he shared his concerns personally with Mexican President Enrique Pena Nieto about trade and illegal immigration – calling anew for changes to NAFTA and asserting the “right” to build a border wall – during a surprise visit to Mexico just hours before he is set to deliver an immigration policy speech in Arizona.

The Republican presidential nominee visited Mexico at Pena Nieto’s invitation. The two leaders met privately in Mexico City, before they addressed the press together.

“We had a very substantive, direct and constructive exchange of ideas,” Trump said.

Trump, who has made illegal immigration a centerpiece of his campaign, called the issue a "humanitarian disaster" that must be solved. As for perhaps his most controversial proposal on the matter -- building a border wall, and making Mexico pay for it -- Trump said they touched on the issue in their meeting, though he did not insist Wednesday that Mexico foot the bill.

“We did discuss the wall. We didn’t discuss payment of the wall,” Trump told reporters, while saying either country has a "right" to build such a barrier.

After the meeting, Mexican President Enrique Peña Nieto tweeted that he made it clear "that Mexico will not pay for the wall."

The Trump campaign responded saying the meeting was "not a negotiation" and that it would have been "inappropriate" to bring up the candidate's proposal to build a wall along the border.

Trump, standing next to Pena Nieto during joint remarks, also said he shared his "strong view" that NAFTA has helped Mexico more than the U.S. and must be overhauled.

Both leaders assumed a measured and respectful tone at the podium that set aside the tensions that have emerged over the past year's U.S. presidential campaign.

Pena Nieto, speaking through a translator, said their neighboring countries will face “common challenges” no matter who is the next president and urged a relationship based on “mutual respect.”

The Mexican president said he and Trump had an “open” discussion, acknowledging the countries face a “joint challenge” on their shared border – he said this includes addressing the flow of weapons into Mexico, as well as the flow of illegal immigrants heading north.

He told Trump: “We might disagree on several issues, but your presence here … shows that we do have fundamental common ground.”

The meeting, which was ridiculed by the Hillary Clinton campaign, comes after Trump has spent much of the presidential race railing against illegal immigration. He has singled out Mexico, accusing the country of sending over criminals and rapists.

His rhetoric, coupled with calls for a border wall and mass deportations, have stoked tensions with Latino voters and Mexican government officials – even as Trump lately has signaled potential changes in his immigration policy platform, which he expects to address in detail at a rally in Phoenix on Wednesday night.

Those tensions flared as Trump was en route to Mexico City. Former President Vicente Fox told CNN that Trump is “not welcome” by the Mexican people, calling it a “political stunt.”

Trump fired back on Twitter, saying Fox “invited me when he apologized for using the ‘f bomb,’” referring to when Fox said he wasn't going to pay for "that f-----g wall."

The Trump-Nieto meeting was only announced Tuesday night, stoking speculation over what both men hoped to achieve.

Earlier in the day, campaign manager Kellyanne Conway told Fox News the two would discuss illegal immigration, trade and drugs. Trump running mate Mike Pence said they would begin a conversation about a proposed border wall, along with other issues.

“He’s going to begin a dialogue with Mexico on issues … that we differ on … but also, issues of common interest,” Pence told Fox News.

“I think today is more about a relationship,” Pence said.

The visit comes as Trump looks to clarify his stance on immigration. Trump has called for the deportation of illegal immigrants living in the U.S. and building a wall along the Mexican border, while having Mexico pay for it.

Recently, Trump has signaled he may soften his stance a bit after meetings with Hispanic leaders.

Conway said on “Fox News Sunday” that Trump wants to find “the fair and humane way” to address the issue.

Last week, Pena Nieto — who has been critical of Trump's insistence that Mexico would pay for the wall — invited both the Republican nominee and Democrat Hillary Clinton to visit his country. Trump confirmed on Twitter late Tuesday that he had accepted Pena Nieto’s invitation.

Clinton, though, took a shot at Trump’s trip during an address earlier Wednesday to the American Legion convention in Cincinnati.

“It certainly takes more than trying to make up for a year of insults and insinuations by dropping in on our neighbors for a few hours and then flying home again,” Clinton said. “That is not how it works.”

Clinton’s campaign also said in a statement that Trump’s trip to Mexico ultimately doesn’t matter in the long run.

"From the first days of his campaign, Donald Trump has painted Mexicans as 'rapists’ and criminals and has promised to deport 16 million people, including children and U.S. citizens. He has said we should force Mexico to pay for his giant border wall. ... What ultimately matters is what Donald Trump says to voters in Arizona, not Mexico, and whether he remains committed to the splitting up of families and deportation of millions."

A senior campaign official told Fox News that Clinton will meet with Pena Nieto at the "appropriate time."

Trump was already out West on Tuesday for a campaign stop near Seattle, giving him enough time to jet down to Mexico for a brief visit before his evening speech on Wednesday.

Foreign trips by presidential candidates, even to a neighboring country such as Mexico, are an enormous logistical and security undertaking.

New Jersey Gov. Chris Christie, a close Trump adviser, has been among those pushing Trump to make the trip, according to a person familiar with their conversations. Christie made his own successful trip to Mexico City in September 2014, and has a warm relationship with the Mexican president.

The Associated Press contributed to this report.