Mexico's Finance Minister Luis Videgaray resigned on Wednesday following Donald Trump's controversial visit to the country, with the US Republican presidential candidate boasting it showed his trip had been a success. "I let them know where the United States stands," Trump said during a televised forum with Democratic rival Hillary Clinton. "And if you look what happened, the aftermath today, people that arranged the trip in Mexico have been forced out of government. That's how well we did." Videgaray, a close confidant of President Enrique Pena Nieto, stepped down earlier Wednesday amid fallout from the New York billionaire's visit which he helped arrange. Pena Nieto said he had accepted Videgaray's resignation but made no mention of reports he played a crucial role in setting up Trump's Aug. 31 meeting with the president. Pena Nieto has faced a barrage of criticism over his decision to hold talks with Trump, who has threatened to make Mexico pay for a wall on the border to stop migrants from entering the United States illegally. He has also vowed to deport millions of Mexican immigrants illegally living in the United States, and cancel trade agreements with Mexico. The Washington Post reported last week that Videgaray was a leading advocate for the sit-down at Los Pinos, serving as the behind-the-scenes liaison with Trump's campaign. Videgaray saw the meeting as a political risk worth taking in case Trump was elected, the Post said. But the visit backfired on the president, with Mexicans voicing outrage that a US politician who has branded Mexican migrants as "rapists" would get such a prestigious invitation. The president's approval rating has since sunk to 23 percent, according to one poll. More than 88 percent of Mexicans expressed displeasure over Trump's visit, according to a survey by the Mitofsky polling firm. Pena Nieto told Milenio television this week that he took the decision to invite Trump, and that "nobody recommended it to me." A long-time aide, Videgaray managed Pena Nieto's presidential campaign in 2012. Luis Carlos Ugalde, director general of the consultancy Integralia Consultores, said Videgaray's resignation could be linked to the Trump visit. "I suppose it has to do with the fact that the political cost for the president has been very high," he said. Videgaray's role compromised his ability to negotiate the budget with the Congress this week, he added. Meade, who served as foreign minister for Pena Nieto and finance minister under former president Felipe Calderon, defended Trump's visit in a newspaper interview published prior to Videgaray's resignation. "It was useful for the country," he told El Universal. Trump said at a joint news conference after his meeting with Pena Nieto that his demand that Mexico pay for a wall along the US border had not been discussed. Criticized for not challenging Trump in front of cameras, Pena Nieto later said that he had privately told the brash New York real estate tycoon that his government would not pay for a wall. Pena Nieto has defended his decision to meet Trump as necessary to open dialogue with someone who could possibly become his counterpart in the United States after the November election. The president also invited Clinton, who declined this week. Videgaray's departure comes with the economy not performing as well as hoped, shrinking by 0.3 percent in the second quarter, while the peso has dropped against the dollar. He was also ensnared in another scandal, over his purchase of a home from a government contractor. The same contractor had sold a mansion to Pena Nieto's wife, the former soap opera star Angelica Rivera, raising questions about conflicts of interest. Although an investigation led by the minister for public administration cleared Videgaray and Pena Nieto of wrongdoing last year, critics questioned the probe because it was conducted by someone the president had picked. Scandals aside, Videgaray was known as the "intellectual architect" of a series of major structural reforms Pena Nieto drove through Congress, Ugalde said. "In his handling of the economy, there are mixed points of view," he said. "Some say he did well, others say the debt has increased."