President Enrique Peña Nieto on Wednesday replaced his finance minister, widely seen as the architect of Donald Trump’s trip to Mexico, after the U.S. presidential candidate’s visit caused a firestorm of protest here.

Peña Nieto offered no explanation for the resignation of Luis Videgaray, one of his closest aides and the protagonist of some of the government’s signature economic reforms. But it came a week after the Mexican leader appeared to deferentially greet a politician who has antagonized Mexicans with his harsh criticism of immigrants and his vow to build a huge border wall.

Peña Nieto’s decision to host Trump has provoked one of his most severe political crises since he took office in 2012, with even his own cabinet deeply divided over the move.

“The political cost [of the visit] was extremely high for Peña Nieto, and he was obliged to find someone to blame,” said Alberto Arnaut, a political science professor at the College of Mexico, explaining the minister’s departure.

The Trump visit, he said, “was a monumental failure.”

During a speech at the American Legion National Convention in Cincinnati, Donald Trump spoke about his meeting with Mexican President Enrique Peña Nieto, saying he had expressed "deep respect" for the Mexican people. (The Washington Post)

Political leaders around the world have expressed concern about a possible victory by Trump, who has threatened to slap new tariffs on key U.S. trading partners, reevaluate current NATO commitments and lessen the protections provided by the U.S. nuclear umbrella.

But Mexico’s leadership has been particularly unnerved by the unconventional Republican nominee. Mexico is heavily dependent on the United States for trade and investment; 1 in 10 Mexican citizens lives north of the border, part of a diaspora that sends home billions of dollars in remittances each year.

Videgaray, who had served as the Mexican government’s behind-the-scenes liaison to the Trump campaign, and his allies advocated the visit as a chance to defend Mexican interests and calm financial markets worried about how a possible Trump victory in November might harm Mexico’s economy, according to Mexicans familiar with the deliberations. But Trump followed his Mexico City trip with a defiant speech in Phoenix vowing to crack down on illegal immigrants and build a massive border fence — while forcing Mexico to pay for it.

A recent poll found that 85 percent of Mexicans thought it had been a bad idea to bring the U.S. presidential candidate to their country. Trump’s visit prompted opponents in Mexico City to plan a protest march for Sept. 15, the eve of Mexico’s independence day, calling on Peña Nieto to step down.

Speaking at a news conference Wednesday in the presidential palace, flanked by Videgaray and other ministers, Peña Nieto praised his close ally for his four years at the helm of the Finance Ministry, saying he had been committed to “further the transformation of Mexico.” Videgaray’s work has “strengthened public finances and increased tax revenue in an unprecedented way, with less dependence on oil revenue,” the president added.

The Mexican leader was losing not just a key minister but also a trusted aide. Videgaray, an MIT-educated economist, had worked with Peña Nieto when he was a governor and later ran his campaign for president. But the Mexican president’s approval ratings had been languishing even before the Trump visit, and he has been pilloried relentlessly in recent days.

Peña Nieto appointed José Antonio Meade, Mexico’s social development minister and a popular former foreign minister, to take over as finance minister.

At the start of the Peña Nieto administration, Videgaray was perhaps the best-known member of a group of young, hotshot technocrats around him who pledged to reboot Mexico’s economy and society and bring a reform-minded agenda to the Institutional Revolutionary Party, which had ruled for much of the past century.

But during Videgaray’s tenure as minister, Mexico’s economy has been characterized by plodding growth and a weakening peso. A steep drop in world oil prices has hurt the country and dampened enthusiasm for a bold plan to open up the country’s crucial oil industry to foreign investment. Videgaray helped craft some of the key economic reforms, including restructuring the tax system with an aim to expand the number of contributors.

His supporters described him as a capable financial mind who kept the economy stable during a turbulent time. “I believe, in general, Videgaray has delivered well,” said Gabriel Guerra Castellanos, a consultant and media analyst.

But government deficits and the public debt grew during Videgaray’s tenure, and critics saw him as arrogant. Many Mexicans opposed his tax increases.

The driving force behind Videgaray’s abrupt departure appeared to be the Trump visit. Many here felt humiliated that Peña Nieto would host the candidate.

The trip also divided Peña Nieto’s government. Some cabinet members, such as Foreign Minister Claudia Ruiz Massieu, had argued against inviting the candidate.

The government is expected to present its 2017 budget on Thursday. Peña Nieto said that the government would be “tightening its belt” but that there will “not be new taxes nor increases in existing ones.”

“The adjustments will fall on the government, and not on the people,” he said.