By Dave Graham

MEXICO CITY (Reuters) - Donald Trump's combative style has buffeted Mexico's president for months, but deeply unpopular Enrique Pena Nieto may end up thanking the new U.S. president for prompting offended Mexicans to rally behind their leader.

From billionaire business magnate Carlos Slim to political opponents, there has been a groundswell of support for Pena Nieto, who has cut a lonely figure in months of bruising encounters with Trump.

Often referred to by his initials EPN, Pena Nieto is laboring under the worst approval ratings of any Mexican president in decades due to discontent over corruption, gang violence, sluggish growth and a jump in fuel prices.

Trump's threats to scrap the NAFTA trade deal with Mexico and build a border wall have caused anger and left Mexicans feeling fearful for the future. His challenge to Pena Nieto on Thursday - saying he should skip a planned summit between the two leaders if Mexico wasn't willing to pay for the wall - was the final straw.

Pena Nieto replied a couple of hours later that he had canceled his meeting with Trump, one of the president's biggest ever hits on Twitter, getting more "likes" than when he personally broke news of the capture of notorious drug lord Joaquin "El Chapo" Guzman in January of last year.

"Bravo EPN!," cheered former President Vicente Fox, who had initially condemned Pena Nieto for inviting Trump to Mexico for talks last August, and who has waged a colorful and expletive-ridden campaign against the Republican on Twitter.

Pena Nieto and Trump talked for about an hour by phone on Friday, pledging to work out their differences and agreeing not to speak about the wall in public for now.

Meanwhile, calls for unity grew in Mexico, led by Slim, a normally media-shy 76-year-old who gave a 90-minute news conference in support of the government on Friday.

"This is the most surprising example of national unity I've seen in my life," said Slim, who spent several years in the past decade as the world's richest man. "We have to back the president of Mexico so he can defend our national interests."

Story continues

Senior opposition leaders also urged a common front.

"It's time to show unity and our commitment to Mexico," Alejandra Barrales, head of the center-left Party of the Democratic Revolution (PRD), said on Twitter.

Pena Nieto's credibility has been battered by a widespread public perception that he has failed to battle corruption and indeed even encouraged it since a conflict-of-interest row embroiled him, his wife and a top minister in late 2014.

Some opposition critics fear the government will try to use Trump as a screen to distract from its failings. However, two senior officials told Reuters they hoped Pena Nieto would seize the moment to act quickly and decisively to improve his image.

Expressions of dismay at Trump's behavior towards Mexico have almost become a national pastime, and talk of boycotts against U.S. companies is gathering steam on social media.

Slim, when asked about boycotting at his news conference, said it wasn't a good idea to turn on U.S. companies, which are creating jobs in Mexico.

Some foreign companies voiced support for Mexico too.

"I feel Mexico is being subjected to terror at the moment," said Andreas Schindler, co-owner of German fruit wholesaler Don Limon's parent Pilz Schindler, by phone from Hamburg. "We're right behind Mexico."

(Reporting by Dave Graham; Editing by Simon Gardner and Mary Milliken)