MEXICO CITY — One of President Enrique Pena Nieto’s closest advisers and confidants, Finance Secretary Luis Videgaray, resigned Wednesday in a move seen as linked to the unpopular decision to invite Republican presidential candidate Donald Trump to visit Mexico.

Pena Nieto has taken responsibility for inviting Trump, but a former government official familiar with the workings of the administration said Videgaray would have played a preponderant role in the decision. Newspaper columnists in Mexico have reported Videgaray was behind last week’s visit, after which Pena Nieto was criticized for not being forceful enough in rejecting Trump’s proposals and comments about Mexico.

Videgaray “was the architect” of Trump’s visit, because he was the adviser that Pena Nieto had “the most reliance on, and was closest to,” said columnist and political analyst Raymundo Riva Palacio.

Even Trump himself said Videgaray’s resignation was related to his visit. Trump told a televised U.S. national security forum Wednesday night that “the people that arranged the trip in Mexico have been forced out of government. That’s how well we did.”

Videgaray acted as Pena Nieto’s campaign manager during his 2012 election campaign and has been seen as the architect of many administration policies. He led Mexico’s Treasury Department and is sometimes referred to as treasury secretary or minister, but because he oversaw budgets and fiscal policies, his role was closer to that of a finance secretary.

He has shared both in the president’s triumphs and embarrassments. In 2014, Videgaray acknowledged he had bought a house from the same government contractor that sold a mansion to Pena Nieto’s wife, Angelica Rivera, in the administration’s deepest scandal.

Pena Nieto thanked Videgaray for leading financial reforms during a ceremony at which the president announced he was accepting the resignation. He did not announce a new post for Videgaray.

“He has been an official very committed to Mexico, and very loyal to the president,” Pena Nieto said.

Former finance secretary Jose Antonio Meade, who has since served as foreign relations secretary and social development secretary, will replace Videgaray. Luis Enrique Miranda Nava will take over the social development post.

Pena Nieto said Meade will be in charge of turning in a primary budget surplus for next year, meaning government spending will have to be less than revenues, not including interest payments on debt.

In comments to local media, Meade defended the president’s meeting with Trump, saying it had lowered the risk of confrontations and helped moderate some of Trump’s policy proposals, especially his vow to change the North American Free Trade Agreement. Pena Nieto has said the meeting was needed to build bridges in case Trump is elected.

But Pena Nieto was ridiculed for not confronting Trump more directly during the visit about him calling migrants from Mexico criminals, drug-runners and “rapists” and promising to build a border wall and force Mexico to pay for it. The wall proposal has been criticized widely and fiercely in Mexico.

Speaking at a town hall last Thursday where he fielded questions from young people, Pena Nieto sought to defend the decision to invite Trump to visit.

He said the easier path would have been to “cross my arms” and do nothing in response to Trump’s “affronts, insults and humiliations,” but he believed it necessary to open a “space for dialogue” to stress the importance of the U.S.-Mexico relationship.

“What is a fact is that in the face of candidate Trump’s postures and positions, which clearly represent a threat to the future of Mexico, it was necessary to talk,” Pena Nieto said hours after his annual state-of-the-nation report was delivered to congress. “It was necessary to make him feel and know why Mexico does not accept his positions.”

Pena Nieto acknowledged the “enormous indignation” among Mexicans over Trump’s presence in the country and repeated that he told the candidate in person that Mexico would in no way pay for the proposed border wall.

The president came under fire for not responding to Trump’s mention of the wall during a joint news conference after their meeting Aug. 31, something he has since sought to correct.

A day later, Trump tweeted that Mexico would pay for the wall. Pena Nieto fired back his own tweet saying that would “never” happen.

Democratic presidential candidate Hillary Clinton, also invited to visit by Pena Nieto, said this week that she won’t be coming to Mexico before Election Day. She called Trump’s quick stop in Mexico City “an embarrassing international incident.”


Associated Press writer Paul Haven contributed to this report.