President Enrique Pena Nieto appointed his former finance minister, who Donald Trump called a “wonderful man,” as Mexico’s foreign minister Wednesday as he prepares for the change of command in Washington. Luis Videgaray resigned from the cabinet in September after helping to arrange a visit by Trump, which sparked public outrage with Pena Nieto. After his resignation, Trump took to Twitter to praise Videgaray, saying “Mexico and the United States would have made wonderful deals together” if he had remained in office. The new top diplomat will have his work cut out for him. Trump has repeatedly promised to end or renegotiate the North American Free Trade Agreement, which has made Mexico an export powerhouse, and to make Mexico pay for a border wall to keep out undocumented immigrants, some of whom he called criminals and rapists. Ford Motor Co. on Tuesday said it will scrap plans to build a $1.6 billion plant in Mexico after coming under criticism from Trump. Videgaray showed his negotiating skills in helping shepherd a package of overhauls under Pena Nieto’s government, including a tax increase, that culminated in the nation’s opening its oil industry to foreign investment, said Duncan Wood, director of the Mexico Institute at the Woodrow Wilson International Center for Scholars in Washington. “He’s the right man at the right time,” Wood said. “He’s very well respected in the U.S., not just by Trump and his team but by the investment community. He’s better prepared than anybody else for the task of negotiating and dealing with the incoming administration.” Videgaray, a former investment banker, has worked for Pena Nieto since the president first became a governor of the state of Mexico in 2005. While analysts had seen him as a potential candidate to follow in the president’s footsteps in the national election of 2018, or to become the candidate for Pena Nieto’s Institutional Revolutionary Party in the state of Mexico governor’s election this year, that speculation had ended after criticism of Trump’s visit. The U.S. election changed things. Four months after telling associates he planned to return to the private sector, Videgaray takes control of a sprawling ministry that will be at the forefront of efforts to protect Mexico’s interests against any threats from the new U.S. president, who takes office Jan. 20. Videgaray is charged with protecting the rights of millions of Mexicans living in the U.S. through a network that includes about 50 consulates. Videgaray has been instructed to “accelerate the dialogue and our contacts so that, from the first day of the new administration, we can establish the basis for a constructive working relationship” Pena Nieto said in a mid-day message at the presidential residence of Los Pinos. Flanked by Videgaray, who sported a new salt and pepper beard, and outgoing Foreign Minister Claudia Ruiz Massieu, Pena Nieto stood in the same spot where he and Trump addressed the media following the late-August meeting that helped speed Videgaray’s departure. “Videgaray has two challenges,” Wood said. “One is to make sure that Nafta is a functioning treaty a year from now. The second is to really explain to the Trump administration the importance of the bilateral relationship with Mexico and take it beyond just the economics.”