Leftist populist Andres Manuel Lopez Obrador is on the brink of a historic presidential win as an exit poll gave him an overwhelming lead and both of his chief rivals conceded defeat.

The survey by Consulta Mitofsky and broadcast by the Televisa network said Mr Lopez Obrador had a 16 to 26-point lead over his nearest rival, conservative Ricardo Anaya, and a slightly larger edge over Jose Antonio Meade of the ruling Institutional Revolutionary party.

"The tendency favors Andres Manuel Lopez Obrador. ... I recognise his triumph," Mr Anaya said in a speech to supporters.

Minutes earlier Mr Meade had also conceded, saying "for the good of Mexico, I wish him the greatest success."

Mr Lopez Obrador, better known as AMLO, has said he will transform Mexico if victorious in his third bid for the presidency, ousting the "mafia of power" he claims has looted the country and ruling for the poor.

"There is a lot of inequality, a lot of violence in this country," said Mr Lopez Obrador voter Hugo Carlos, 73. "This situation has to be changed."

US president Donald Trump , meanwhile tweeted his congratulations, saying: "I look very much forward to working with him. There is much to be done that will benefit both the United States and Mexico!"

Exit polls by Consulta Mitofsky also forecast clear gubernatorial wins for allies of Mr Lopez Obrador's Morena party in four of eight state races on the ballot plus for the head of government in Mexico City. The central highland state of Guanajuato was predicted to go to a candidate of the conservative National Action Party.

Mr Lopez Obrador has pledged to give scholarships or paid apprenticeships to youth, and increase support payments for the elderly.

"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, who lined up at a Mexico City precinct to vote for Ricardo Anaya, who is running second in polls for a right-left coalition.

All the candidates are lambasting President Donald Trump's policies against migrants and Mexico, but voters were wondering who could best deal with Mr Trump.

Sunday's elections for posts at every level of government are Mexico's largest ever and have become a referendum on corruption, graft and other tricks used to divert taxpayer money to officials' pockets.

Many saw this election as Mr Lopez Obrador's best shot at the presidency after 12 years of near-permanent campaigning with his anti-establishment message falling on receptive ears amid widespread disillusionment with politicians.

"The corrupt regime is coming to its end," Mr Lopez Obrador said at his final campaign event on Wednesday. "We represent modernity forged from below."

Much of the popular ire has been aimed at unpopular President Enrique Pena Nieto's Institutional Revolutionary Party (PRI), whose market-oriented economic reforms have yet to benefit many Mexicans, and Mr Meade struggled during the campaign to escape popular rejection of the party.

Mr 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 it is unclear if his new allies in the leftist Democratic Revolution Party will actually turn out for someone from the other end of the ideological spectrum.

Sunday was the first time that an independent candidate appears on the ballot.

Jaime "El Bronco" Rodriguez fought for attention with a horse-mounted "everyman" campaign and by tossing out policy bombs like his proposal to cut off the hands of public officials caught stealing. Without the big party machinery it was an uphill battle.

It is also the first time Mexicans living abroad can vote for down ballot races like senators. More than 181,000 received ballots and the 97,000 that the National Electoral Institute had got back by Friday morning were already double what they got in 2012.

Casting his own vote, Mr Pena Nieto promised to work with whoever wins on the transition.

"The president of the republic and his government will be absolutely respectful and support the authorities that are elected," Mr Pena Nieto told reporters.