MEXICO CITY — One of President Enrique Peña Nieto’s top ministers and closest allies resigned on Wednesday, an apparent casualty of Mr. Peña Nieto’s wildly unpopular meeting last week with Donald J. Trump.

The spectacle of the Mexican president standing next to the Republican candidate who has disparaged Mexicans prompted widespread dismay and anger here, and reportedly divided Mr. Peña Nieto’s cabinet. Luis Videgaray, the finance minister who stepped down on Wednesday, had championed the idea of inviting Mr. Trump to Mexico City over the objections of other ministers, according to several Mexican news media reports, though Mr. Peña Nieto insisted it was his own initiative.

Mr. Peña Nieto announced Mr. Videgaray’s resignation at a news conference.

He did not give a reason for Mr. Videgaray’s departure. But some analysts interpreted it as the latest, and most dramatic, effort by the president to regain the trust of the Mexican public following his meeting with Mr. Trump, the Republican presidential nominee, who has made criticism of Mexicans and Mexico an incendiary motif of his campaign.

“It will help mitigate the anger,” said José Antonio Crespo Mendoza, a professor of politics at Centro de Investigación y Docencia Económicas, a Mexican research and higher education center. “President Peña Nieto realized things could not stay as they were, and that they could no longer insist that it had been a good call” to invite Mr. Trump.