Leftist politician, commonly known as AMLO, handed broad mandate for change after an election driven by widespread frustration and anger of the country's corruption and violence.
Furious at spiralling corruption and violence, Mexican voters unleashed a political earthquake Sunday by electing a leftist firebrand as president and giving him a broad mandate to overthrow the political establishment and govern for the poor.
A late-night official quick count from electoral authorities forecast that Andrés Manuel López Obrador would win with between 53 percent and 53.8 percent of the vote, a remarkable margin not seen in the country for many years. A prominent exit poll predicted that his party allies were poised to score huge wins in the Senate and lower house, possibly absolute majorities in both.
López Obrador, who campaigned on vows to transform Mexico and oust the "mafia of power" ruling the country, rode widespread voter anger and discontent with the governing Institutional Revolution Party, or PRI, of President Enrique Peña Nieto and had led opinion polls since the beginning of the campaign.
The PRI, which dominated Mexican politics for nearly the entire 20th century and recaptured the presidency in 2012, was set to suffer heavy losses not just for the presidency but in down-ballot races as well.
In brief remarks at a hotel in central Mexico City, López Obrador called for reconciliation after a polarising campaign and promised profound change that respects the law and constitutional order.
"I confess that I have a legitimate ambition: I want to go down in history as a good president of Mexico," said López Obrador, who won after losses in the previous two elections. "I desire with all my soul to raise the greatness of our country on high."
The president-in-waiting devoted much of his speech to appealing to citizens of all stripes and seeking to reassure those who have eyed his candidacy nervously.
"This new national project will seek to establish an authentic democracy and we do not intend to establish a dictatorship," López Obrador said. "The changes will be profound, but in accordance with established order."
Conservative Ricardo Anaya of a right-left coalition and the PRI's José Antonio Meade acknowledged defeat shortly after polls closed nationwide. The quick count had them around 22 percent and 16 percent, respectively.
"The tendency favors Andres Manuel López Obrador. ... I recognise his triumph," Anaya said in a speech to supporters.
"For the good of Mexico, I wish him the greatest success," Meade said minutes earlier.
López Obrador supporters began wild celebrations in Mexico City, cruising up and down the central Paseo de la Reforma boulevard honking horns to the tune of "Viva Mexico!" and waving Mexican flags from car windows and moon roofs.
Thousands poured into the sprawling main square known as the Zocalo, where the 64-year-old former mayor had called on his backers to rally. Many danced to the trills of mariachi music.
López Obrador spoke to the crowd there around midnight, saying to loud applause: "Today one stage has ended and we are going to begin another one — we are going to transform Mexico!"
Retired teacher Susana Zuniga beamed and said the country was experiencing a moment similar to the Mexican Revolution a century ago.
"The people are fed up," Zuniga said. "That is what brought us to this."
US President Donald Trump tweeted congratulations: "I look very much forward to working with him. There is much to be done that will benefit both the United States and Mexico!"
López Obrador said individual and property rights would be guaranteed, promised respect for the autonomy of the Bank of Mexico and said his government will maintain financial and fiscal discipline.
He said contracts obtained under energy reforms passed under President Enrique Peña Nieto will be scrutinised for any corruption or illegality, but otherwise contracts will be honored:
"There will be no confiscation or expropriation of assets. ... Eradicating corruption will be the principal mission," he said.
López Obrador also spoke of support for migrants and said the most forgotten and humble people of Mexico will be given preference in his government. He said he will seek a relationship of "friendship and respect" with the United States. And rather than the use of force to fight spiralling violence, he will look to fix root causes such as inequality and poverty.
"Peace and tranquility are the fruits of justice," Lopez Obrador said.
Third time lucky
Exit polling by Consulta Mitofsky for the Televisa network forecast gubernatorial wins for allies of López Obrador's Morena party in at least four of eight state races on the ballot plus for the head of government in Mexico City. The central state of Guanajuato was expected to go to a candidate of the conservative National Action Party.
Mitofsky predicted Morena allies would take between 56 and 70 seats in the 128-member Senate and between 256 and 291 spots in the 500-seat Chamber of Deputies.
López Obrador, commonly known by his initials, "AMLO," was making his third bid for the country's highest office, having falling short in the 2006 and 2012 elections.
In 2006, rivals convinced voters that his populist message was "a danger for Mexico." In 2012, voters restored the long-dominant PRI to power in hopes that it could cut back-room deals to tamp down rising violence.
But after six years under Peña Nieto, that hasn't been the case. So deep is Mexicans' discontent with the status quo that not only López Obrador but Anaya, Meade and independent candidate Jaime "El Bronco" Rodríguez all claimed to be the ones representing real change.
In the end, Lopez Obrador's rants against the "mafia of power" rang most authentic.
"The anger that the average Mexican feels toward the way things are being governed has favoured López Obrador," said Shannon O'Neil, senior fellow for Latin America Studies at the Council on Foreign Relations. "He's been able to capture the mantle of the person who's on the outside who wants change."
After 12 years of near-permanent campaigning, López Obrador moderated his message somewhat in both substance and style. He said he will govern for the poor and fight rampant corruption, and also pulled back from promises to completely scrap energy and education reforms instituted by the Peña Nieto administration.
He also pledged to increase support payments for the elderly and to give scholarships or paid apprenticeships to young people.
"Now that he has won, he cannot fail this new generation that believes in him," said Mariano Bartolini, a 29-year-old lawyer who voted for López Obrador in the northwestern city of Rosarito, near Tijuana. "It is thanks to us young people who are supporting him that he was able to get more votes than he did in past elections."
López Obrador's rivals argued he could set the country back decades and lead to disaster with an interventionist economic policy.
"I am concerned that some candidates are making proposals that are impossible, because they're very expensive to carry out," said Juan Carlos Limas, 26, an Anaya supporter.
Peña Nieto said in a televised message to the nation that he had congratulated López Obrador and assured him that his administration would work to ensure an orderly transition.
Sunday's elections for posts at every level of government were Mexico's largest ever and became a referendum on corruption, graft and other tricks used to divert taxpayer money to officials' pockets.
Much ire was aimed at the PRI, whose market-oriented economic reforms have yet to benefit many in a country where about half the population is poor. Meade struggled during the campaign to escape discontent with the party, even though he was never a member until it tapped him as an "outsider" candidate.
Anaya tried to harness the youth vote with an emphasis on technology and new ideas, but he divided his own conservative party to take its candidacy and there were doubts his new allies in the leftist Democratic Revolution Party would turn out for someone from the other end of the ideological spectrum.
Sunday's vote was largely peaceful and electoral authorities reported only isolated incidents.