Just a few days ago, Enrique Pena Nieto was a pariah president, dogged by protests and cursed with the lowest approval rating for a Mexican leader in recent history.

No more, thanks to Donald Trump.

Months of Trump's insults to Mexican migrants, threats to build a vast border wall to keep out them out, deport those who've arrived and impose crippling taxes on Mexican exports were met with teeth-clenched restraint by Pena Nieto's government — infuriating many Mexicans.

But when Trump repeatedly insisted Pena Nieto accept paying for the wall, Pena Nieto finally had enough and scrapped a planned Jan. 31 meeting with Trump in Washington.

Suddenly, the nation rallied around him.

"We have to support the president of Mexico, so he can defend the country's interests," said telecom magnate Carlos Slim, the world's fourth-richest man. "I would be very interested in seeing this unity last."

Even the government's most prominent critic, leftist presidential hopeful Andres Manuel Lopez Obrador, has called on Mexicans who three weeks ago were marching in the streets against the government's polices to support Pena Nieto.

Rising crime, a sluggish economy and a series of corruption scandals in his party had already sent the president's popularity reeling. Things got even worse when the government — which originally promised lower fuel prices — imposed a sudden 20-percent increase. Nationwide protests and widespread looting broke out and Pena Nieto's approval ratings collapsed to a historic low of 12 percent in mid-January.

Then came the mini-showdown with Trump.

"Under a national crisis people rally around a leader. Now he's got to keep leading, that's important," said Peter Schechter, senior vice president for strategic Initiatives at the Atlantic Council. "There has to be perception he continues to lead."

Former presidential spokesman Ruben Aguilar saId the popularity bounce for Pena Nieto may be short-lived.

"There is a certain feeling of unity around the president," Aguilar said. "But it is very possible that this sentiment could evaporate."

While most Mexicans were flabbergasted that Pena Nieto chose to meet the Mexico-bashing Trump before the election, many economic and political analysts praised his cautious diplomacy, meant to avoid a potentially catastrophic rupture with a northern neighbor that that buys 80 percent of the country's exports.

But traditional cautious diplomacy may not always work in the Trump era.

"Being friendly, being courteous, now appears to be weak, and Mexico should not and cannot appear to be weak," Aguilar said.

Schechter noted that the spat could increase the popularity of Lopez Obrador, "who espouses weakening ties with the United States. It is a troubling development for a relationship that has few parallels throughout the world."

Lopez Obrador, a former Mexico City mayor who advocates developing the country's internal economy, has already declared his intention to make a third run for the presidency in 2018. Lopez Obrador narrowly lost in his first two tries, but Mexico could be a different, angrier place in 2018 with a wall sealing it off from the United States, millions of deported migrants and a potential recession caused by scrapped trade agreement with its northern neighbor.

Still, Lopez Obrador — a fiery, irascible and unyielding leftist — may suffer if Mexicans start seeing parallels with Trump's behavior.

"I don't see this as automatically implying more votes for Andres Manuel," Aguilar said. "It may instead prove damaging to him, if comparisons are made."

"If they are compared, the Mexican public could think, 'Gee, it's tough to vote for a messianic guy who's going to get into trouble with the United States.'"