Mexico's president on Wednesday revived the career of his fallen former finance minister, appointing him foreign minister just four months after he was replaced in the wake of a controversial visit by Donald Trump.

Luis Videgaray is one of President Enrique Pena Nieto's closest aides, but he was forced out in September, a week after the Trump visit.

Pena Nieto was subjected to a wave of criticism for what many saw as a poorly handled invitation, given the real estate magnate's anti-Mexico rhetoric.

Pena Nieto said on Wednesday that he had tasked Videgaray with accelerating contacts and dialogue with the incoming Trump administration.

Senior diplomats have said that Videgaray was instrumental in arranging Trump's late August visit, in which the government had hoped to impress upon him the need to moderate his tone and reconsider his more divisive campaign proposals.

But within hours of leaving Mexico, Trump was telling a cheering crowd of supporters in Arizona that Mexico would pay for the border wall "100 percent," prompting fresh ridicule of Pena Nieto at home.

Trump has infuriated Mexicans by threatening to carry out mass deportations and rewrite trade treaties crucial to their economy, and by referring to some immigrants from the United States' southern neighbor as rapists or drug runners.