President Enrique Pena Nieto on Wednesday replaced his close ally and finance minister, Luis Videgaray, after the two were heavily criticized for U.S presidential candidate Donald Trump's controversial visit to Mexico last week. A somber-looking Pena Nieto told a news conference that Videgaray, who officials said was the architect of the visit by the Republican nominee for the Nov. 8 U.S. presidential election, would give way to a former finance minister, Jose Antonio Meade. "I want to express here publicly my most generous recognition, not only institutionally but also personally, to someone who has always been a committed collaborator of the government's for driving the transformation of Mexico." Pena Nieto said, speaking directly to Videgaray. Pena Nieto was widely pilloried for hosting Trump at short notice last Wednesday after the New York businessman had underpinned much of his campaign on building a border wall that he said Mexico would pay for to stem illegal immigration. Trump has also threatened to carry out mass deportations and rewrite trade treaties crucial to the Mexican economy, as well as insulting people south of the border by referring to some Mexican immigrants as rapists and drug runners. With economic growth sluggish, the president's popularity at record lows and tensions palpable between the finance minister and other Cabinet members, rumors of Videgaray's impending departure had bubbled under the surface in Mexico for months. The fiery reaction to Trump's visit increased pressure on Pena Nieto to make changes. Senior diplomats said Videgaray had been instrumental in arranging the Trump visit, in which the government had hoped to impress upon Trump the need to moderate his tone and reconsider his more divisive campaign proposals. However, within hours of leaving Mexico, Trump was telling a cheering crowd of supporters in Phoenix, Arizona, that Mexico would pay for the border wall "100 percent," prompting fresh ridicule of Pena Nieto at home. The 48-year-old Videgaray ran Pena Nieto's election campaign, and was widely seen as the president's top aide, who had a huge influence on policy after orchestrating the country's landmark energy, telecommunications, tax and education reforms. The depth of Videgaray and Pena Nieto's bond was highlighted when both were embroiled in conflict-of-interest scandals, after they were found to have acquired property from a favorite government contractor. The new finance minister, Meade, is a friend of Videgaray and had started in the administration as foreign minister before moving to the social development ministry last year. Deputy Interior Minister Luis Miranda, who is said to be a close friend and ally of Pena Nieto, replaced Meade as the head of the social development ministry. His former boss, Miguel Angel Osorio Chong, who led the interior ministry during the jailbreak and eventual recapture of drug lord Joaquin "El Chapo" Guzman, received a boost to his hopes of becoming the ruling Institutional Revolutionary Party's 2018 presidential candidate after avoiding the chop. Among possible PRI candidates for the presidency, Chong tops opinion polls. But he would face a tough fight against rivals from the conservative National Action Party and leftist firebrand Andres Manuel Lopez Obrador. Pena Nieto said that the low-key Meade, who is also seen by some as a possible 2018 candidate for the PRI, would have to get to work immediately, with the 2017 budget proposal due to be announced Thursday. The president said the budget proposal will need to continue with the process of consolidating public finances to reach a primary surplus for the first time in many years. Pena Nieto added there would be no new taxes or tax hikes. The budget proposal will be under scrutiny after rating agency Standard & Poor's last month said it could cut Mexico's credit rating following a marked increase in debt. The economy contracted in the second quarter for the first time in three years, and the collapse in global oil prices has dashed Pena Nieto's hopes that a landmark energy reform would spur a wave of foreign investment. The economy has consistently underperformed expectations during Videgaray's tenure. Videgaray, who has also been rumored as a potential 2017 gubernatorial candidate for the ruling party in the State of Mexico, a populous region next to the capital, will not take another public post, a finance ministry spokeswoman said.