MEXICO CITY (Reuters) - For 13 years, Mexico's perennial political outsider Andres Manuel Lopez Obrador has covered tens of thousands of miles crisscrossing the nation in dogged pursuit of its highest office.
Now the 64-year-old leftist is on the brink of winning Sunday's presidential election, having spent his political career railing against Mexico's establishment.
Years of mounting drug violence, sluggish economic growth and corruption have gradually eroded the credibility of the political class, leaving Lopez Obrador as the last man standing.
Pledging to clean up government, reduce inequality and subdue gang violence, he promises to "transform" a country he says has been debased by the few at the expense of the many.
Commonly known as AMLO, Lopez Obrador has bounced back from two presidential election defeats, two gubernatorial losses and a 2013 heart attack to defy his critics with an unshakeable faith in his ability to tackle Mexico's ills.
"We're the only ones that can put an end to corruption in Mexico," Lopez Obrador told supporters this year in Cintalapa, a town in the impoverished south of the country.
Few politicians have established such a connection with the millions of underprivileged families in Mexico as Lopez Obrador, a baseball fan who regularly campaigns festooned with garlands, flowers and gaudy sombreros from provincial rural communities.
Like U.S. President Donald Trump, the headstrong Lopez Obrador has been the heart and soul of his movement, and victory for him on July 1 could heighten tensions between Mexico and the United States over trade and migration if the two men clash.
The prospect of a showdown between the blunt Lopez Obrador and Trump over the planned U.S.-Mexico border wall and the American's efforts to renegotiate the North American Free Trade Agreement (NAFTA) has both friends and enemies worried.
"There's going to be a clash of vanities, a clash of egos, and who knows where it will end," said Juan Jose Rodriguez Prats, a former party colleague, friend and later adversary of Lopez Obrador who has known him for 40 years.
Born into a family of modest means in the southeastern state of Tabasco, Lopez Obrador worked in the 1970s for the state's indigenous affairs bureau.
At times, he would sleep in the open if he did not make it back home with the indigenous villagers by nightfall.
Once his bastions were across the south. Now, however, he has extended his support into the richer north.
First a member of outgoing President Enrique Pena Nieto's Institutional Revolutionary Party (PRI), he quit the PRI in the 1980s and twice failed to be elected Tabasco's governor, staging a protest march to the capital after his second loss in 1994.
That raised his profile at a time of growing opposition to the PRI, and in 2000 he was elected mayor of Mexico City, where his administration was widely viewed as pragmatic, providing a springboard for his first tilt at the presidency.
Narrowly defeated in the 2006 election, he again claimed he had been robbed. Lopez Obrador then brought large swathes of the capital to a standstill for weeks with huge demonstrations, and declared himself the legitimate president of Mexico.
The protests fizzled out and he began campaigning all over Mexico, speaking in villages that had not seen any political leaders in years, sometimes to only a handful of people, said Polimnia Romana Sierra, one of his aides from 2003 to 2011.
"He spoke with the same energy under a tree in front of 10 people as he did in the full Zocalo," Sierra said, referring to the square in the heart of Mexico City that holds about 100,000 people. "Nobody works the microphone like him."
He became so famous that a village in the southern state of Oaxaca put up road blocks to make him stop there, hailing him as the first politician to visit since Lazaro Cardenas, a hero of AMLO's who nationalized the oil industry in 1938, she said.
"They made (Lopez Obrador) dance with a little old lady," she recalled. Another village pulled the same trick so it could give Lopez Obrador a taste of its coconut milk, she added.
However, he can also sow division.
Since running for Mexico City's local congress for a party allied to him in 2012, Sierra and Lopez Obrador have not spoken because he was unhappy about her entering politics, she said.
That account could not be confirmed by a spokesman for the candidate, though he said it was true that they had not spoken.
"You have to be 100 percent with me, because otherwise you're 100 percent against me," Sierra said of Lopez Obrador.
Sierra, who recalled the split with sadness, is now part of the right-left coalition supporting his rival, Ricardo Anaya, a former head of the centre-right National Action Party (PAN).
MANGA HERO AMLO
Lopez Obrador went back on the road after finishing runner-up again in 2012, and became the focal point of opposition after the PRI formed a loose legislative alliance with the PAN and his old base, the leftist Party of the Democratic Revolution (PRD).
He formed a new party, the National Regeneration Movement (MORENA) and by 2015, senior government officials were tacitly admitting AMLO was in pole position to win the next election.
And as support for the PRI imploded over corruption scandals, record levels of violence and economic growth that fell short of expectations, Lopez Obrador's stature grew.
Sweetening his appeal has been a mellower edition of Lopez Obrador, who, in contrast to previous campaigns, has revelled in the chance to mock himself to confound his detractors.
"I can handle the dirt roads better now," a laughing Lopez Obrador told an audience of university students in April.
Part of the transformation, said his senior campaign aide Tatiana Clouthier, has been Lopez Obrador's wife Beatriz Gutierrez, a forthright feminist who has broadened his appeal among female voters in Mexico.
Using social media, both women have helped soften his once prickly image, tweeting light-hearted pictures of Lopez Obrador as Superman as well as a short manga-style cartoon made by a fan featuring AMLO as a corruption-busting hero.
Yet flashes of the fire that prompted Lopez Obrador to declare "to hell with your institutions" after his 2006 loss still surface. His response in the presidential debates to criticism was often just to point to his massive poll lead.
If Mexico's problems persisted under his rule, critics worry Lopez Obrador's opposition instincts may lead him to keep pinning the blame on others, potentially polarizing the country.
(Reporting by Dave Graham; Additional reporting by Frank Jack Daniel; Editing by Daniel Flynn and Lisa Shumaker)