Mexican Finance Minister Luis Videgaray
© Zuma Press
Mexican Finance Minister Luis Videgaray, seen as the right-hand man to President Enrique Peña Nieto, has resigned and will be replaced by a former finance chief José Antonio Meade.

Mr. Videgaray's resignation comes less than a week after a controversial visit to Mexico by U.S. presidential candidate Donald Trump, which was widely seen as a humiliation for Mexico and its president. Multiple local media reports said the invitation to Mr. Trump was Mr. Videgaray's idea, a claim disputed by him as well as Mr. Peña Nieto.

Mr. Videgaray, a former investment banker and state finance official, won't take a public post for the time being, Finance Ministry spokeswoman Claudia Algorri said.

The economist with a doctorate from MIT was widely seen as the brains behind the Mexican president and the driving force behind a series of high-profile reforms in the past few years that includes opening Mexico's closed oil industry to private investment for the first time since 1938.

"He's leaving with a superb track record on reforms, and will be remembered as one of the main architects of the reform efforts going back to 2013," said Alonso Cervera, Credit Suisse's chief Latin America economist.

Mr. Videgaray's departure will be a blow to Mr. Peña Nieto, who has relied on Mr. Videgaray as his leading adviser since the president rose to national prominence as governor of the State of Mexico, said Jesus Silva Herzog, a prominent Mexican political analyst.

But in the past two years, Mr. Videgaray has come under fire for tepid growth in the Mexican economy, even as the government ran slightly bigger deficits and added to public debt. He also rankled Mexico's business class by hiking taxes. While he was widely admired outside Mexico, at home he was criticized for being arrogant.

The 47-year-old Mr. Meade has degrees in law and economics, and a doctorate in economics from Yale University and has a long history of working in government.

He was finance minister from 2011 to 2012 under former President Felipe Calderón, and had previously been Mr. Calderon's energy minister. Under Mr. Peña Nieto he has been foreign minister and minister for social development.

"His previous tenure was solid, without being extraordinary. He's seen as very orthodox, which is a good thing given rising debt and the need for a budget adjustment," said Oscar Vera, a leading Mexican economist.

Mr. Meade's return to a key post in Mexican politics could make him a possible contender for the presidency in 2018 for the ruling Institutional Revolutionary Party, analysts said.

For Mr. Videgaray, 48, the end came only days after a surprise visit to Mexico by Mr. Trump last week. The visit was widely seen as a disaster for Mr. Peña Nieto, who was criticized for not demanding Mr. Trump apologize for his outspoken remarks over the past 18 months about Mexico and Mexican immigrants to the U.S.

For his part, Mr. Trump has claimed the visit was a great success, and repeated his claim that Mexico will pay for an eventual border wall between both countries.