Left-wing candidate Andrés Manuel López Obrador has claimed victory in Mexico's presidential election, saying "profound change" is coming.
The ex-Mexico City mayor, known by his initials Amlo, is projected to win about 53%. His rivals have conceded in a crushing defeat for the main parties.
Mr López Obrador's key pledge has been to tackle the "evil" of corruption.
He has also been highly critical of President Donald Trump and ties with the US will now be closely watched.
Relations with Washington have been hugely strained, with Mr Trump strongly criticising Mexico over trade and migration. Mr Trump has sent a tweet of congratulations.
What has López Obrador said?
Late on Sunday, the 64-year-old promised to respect civil liberties and said he was "not looking to construct a dictatorship, either open or hidden".
Some opponents have expressed fears that his leftist and populist policies could damage the already sluggish economy and turn Mexico into "another Venezuela", which is suffering a deep economic crisis and rampant inflation.
Hailing a "historic night", Mr López Obrador called on all Mexicans to reconcile and repeated his campaign pledge to review energy contracts for signs of corruption.
"Corruption is... the result of a decadent political regime. We are absolutely convinced that this evil is the main cause of social and economic inequality, and also that corruption is to blame for the violence in our country," he said.
He has insisted that no-one involved in corruption will be spared, not even those he calls "brothers-in-arms".
So what are his other main policies?
On combating Mexico's record levels of violence, much of it related to drug cartels, Mr López Obrador said he would have daily meetings with his security cabinet, which under him, he said, would be under a "unified command".
Sunday's election followed one of Mexico's deadliest campaigns in decades with more than 130 political candidates and party workers killed.
During the campaign Mr López Obrador had often used confrontational language when referring to Mr Trump, but struck a more conciliatory note in his victory speech, saying he would seek "friendly relations".
He also tried to reassure the business sector, saying there would be no nationalisation and that he would respect private business. He also said his government would be fiscally disciplined and taxes would not be raised.
On social policies, he said he would double pensions for the elderly upon taking office on 1 December as a first step to reducing Mexico's disparate income levels.
Andrés Manuel López Obrador - a brief biography
- Born to a family of shopkeepers on 13 November 1953 in the rural community of Tepetitán, in southern Tabasco state
- Known popularly as Amlo, which is an acronym using the full initials of his name
- Elected Mexico City mayor in 2000
- After losing the presidential elections in 2006 and 2012, he ran again this time under a three-party coalition led by the leftist National Regeneration Movement party (Morena) he founded in 2014
- The self-styled anti-establishment figure has now ended the dominance of the PRI and PAN parties he called the "mafia of power"
What have his rivals said?
The latest figures from the Mexican electoral institute show Mr López Obrador has won more than double the votes of his nearest challenger. It is the widest victory since the 1980s.
Ricardo Anaya, candidate for the conservative National Action Party (PAN), looked set to be runner-up to Mr López Obrador.
"I recognise his triumph, I express my congratulations, and I wish him the greatest success for the good of Mexico," Mr Anaya said.
Ruling party candidate José Antonio Meade, who lies in third place according to initial results, told supporters that he wished the winner "the greatest success".
Mr Meade's Institutional Revolutionary Party (PRI) has dominated Mexican politics for much of the past century but has slumped in popularity.
The electoral institute figures put official turnout at 62.7%. As well as a new president, 128 senators and 500 deputies in Congress were elected, in addition to state and local officials.
Mr López Obrador's coalition is set to have a majority in the lower house and possibly the Senate.
How will US-Mexico relations be affected?
Mr López Obrador had been the candidate most critical of Mr Trump and had said he would make the US president "see reason", branding his anti-immigrant policies "irresponsible" and "racist".
Congratulations to Andres Manuel Lopez Obrador on becoming the next President of Mexico. I look very much forward to working with him. There is much to be done that will benefit both the United States and Mexico!— Donald J. Trump (@realDonaldTrump) July 2, 2018
Mr Trump has riled Mexico by saying he will renegotiate the North American Free Trade Agreement (Nafta) and build a wall along the US-Mexico border.
His hardline stance on migration - particularly the separation of migrant families at the US border - has brought widespread condemnation.
Some 2,000 children remain separated from their migrant parents, despite Mr Trump agreeing to curtail the policy.
In his victory speech, Mr López Obrador said: "We will pursue a relationship of friendship and co-operation with the United States, always rooted in mutual respect and in the defence of our fellow Mexicans who live and work honourably in that country."