(Adds more quotes from Videgaray, background)
HAMBURG, July 7 (Reuters) - U.S. President Donald Trump hailed progress on trade after meeting his Mexican counterpart on Friday, as Mexico's government said it expected a general agreement on reworking the North America Free Trade Agreement (NAFTA) by the end of 2017.
For the first time since becoming president in January, Trump met Mexican President Enrique Pena Nieto, whose foreign minister, Luis Videgaray, said he expected talks on renegotiating NAFTA to start on Aug. 16., the earliest possible date.
The meeting at the Hamburg leaders' summit of the Group of 20 economies was keenly anticipated in Mexico, and officials were quick to stress talks had been productive, despite Trump repeating that Mexico would pay for his planned border wall.
"We're negotiating NAFTA and some other things with Mexico and we'll see how it all turns out, but I think that we've made very good progress," Trump said after the meeting.
In response to a shouted question from a reporter about whether he still wants Mexico to pay for the border wall, which aims to keep out illegal immigrants, Trump said, "Absolutely."
Pena Nieto, whom Trump called his "friend," said the meeting would "help us continue a very strong dialogue" on NAFTA, while his aides emphasized that they had not discussed the wall.
NAFTA underpins more than $1 trillion worth of trilateral trade between the United States, Mexico and Canada. Videgaray, who was present at the talks, told reporters afterwards it had been a "big part of the conversation" with Trump.
"We expect to have a meaningful, constructive, modernization of the agreement that is good for the three nations," the minister said. "And we think there is a lot of room to make it a better agreement for the three nations."
Speaking on Mexican radio, Videgaray also said both governments agreed the renegotiation "should be a relatively quick process" that looks to "generate agreements, at least in general terms, by the end of the year."
Disputes over migration, Trump's border wall - which Mexico has repeatedly said it will not pay for - and his claim that free trade with Mexico costs jobs in the United States, have strained relations between the two neighbors.
Trump has threatened to impose punitive tariffs on Mexican goods to protect U.S. industry, and to pull out of NAFTA altogether if he cannot rework the deal in the United States' favor.
However, especially since Trump stepped back from initiating the process of withdrawing from the pact in April, Mexican officials say business leaders from the NAFTA nations have increasingly coalesced around a shared desire to keep the agreement alive.
There has been some uncertainty about the process because the United States has yet to set out its negotiating objectives. That is due to happen on or about July 16.
In the meantime, issues such as Trump's border wall remain sensitive. Pena Nieto's spokesman, Eduardo Sanchez, called in to Mexican broadcaster Radio Formula from Hamburg, stating that the two presidents did not discuss the wall.
"That subject was not part of the conversation," he said.
The two presidents also explored a possible guest worker program for migrants in the agriculture sector as well as the importance of "modernizing" NAFTA, according to a statement from Mexico's government released after the meeting. (Additional reporting by Dave Graham, Adriana Barrera, Anthony Esposito and David Alire Garcia in Mexico City; editing by Noah Barkin and Jonathan Oatis)