Mexico election: Polls closing after campaign marred by violence
Polls are closing across Mexico in elections marred by some of the worst political violence for decades.
More than 130 candidates and political workers have been killed since campaigning began in September.
The presidential frontrunner is Andrés Manuel López Obrador, 64, the left-wing former mayor of Mexico City who has pledged to crack down on corruption.
The coalition led by his party, Morena, could oust the two parties that have governed Mexico for nearly a century.
Third time lucky?
Analysis by Will Grant, BBC News, Mexico
This has been the most violent election campaign in Mexico in living memory. Now that voting day has arrived, however, many Mexicans see it as an opportunity to remove the government that has led the country to this point.
Millions of ordinary Mexicans are angry at President Enrique Peña Nieto and his administration, particularly over the sluggish economy and widespread corruption, crime and impunity.
The man widely expected to replace him, Andrés Manuel López Obrador who is often referred to just by his initials Amlo, was the runner-up in the last two presidential elections.
He has made tackling corruption the central plank of his election platform, promising to improve wages and pensions by stamping out rampant abuses by the state and the political and business elites.
His opponents, including the centre-right candidate, Ricardo Anaya, have tried to paint him as a populist and a dangerous maverick who cannot be trusted with the economy.
Most polls suggest, however, that a majority of voters have not listened to that message and are prepared to hand Mr López Obrador the presidency, third time around.
How has election day unfolded?
Long queues of voters formed outside schools and community centres as polling day progressed but two more killings of party members were reported - one a member of the Workers' Party in the western state of Michoacan and the other a member of the governing PRI party in the central state of Puebla.
Some 88 million people have been eligible to vote, and have been choosing not only a president but also 128 senators and 500 deputies in Congress as well as state and local officials.
A huge crowd gathered outside the polling station in Mexico City's Tlalpan district to watch Mr López Obrador cast his vote.
He called the election "historic" and told reporters: "We represent the possibility of real change".
His closest rival looks to be Mr Anaya who heads a centre-right coalition. The candidate for the governing PRI party is José Antonio Meade, a former finance minister.
Polling stations began closing at 18:00 local time (23:00 GMT) and the first results are expected in the coming hours.
What is at stake?
If Mr López Obrador wins this time, he will end the dominance in Mexican politics of the Institutional Revolutionary Party (PRI) and the National Action Party (PAN).
He has referred to them as being part of the same "mafia of power".
Mexico is the second largest economy in Latin America and a major oil exporter. However, oil prices have dropped and the Mexican currency, the peso, has fallen sharply against the dollar.
More than 40% of the population lives in poverty. High levels of corruption and violence have led some companies to pull out of the worst affected areas.
Mexico has a reputation for being one of the most dangerous countries in the world for journalists.
Taking on the Trump administration
Even before his own election, US President Donald Trump has continuously attacked Mexico over migration and trade.
Who the next Mexican president will be and how he deals with President Trump and his plans to renegotiate the North American Free Trade Agreement (Nafta) and build a border wall will therefore be key to US-Mexican relations.
Mr López Obrador has been the most critical of Mr Trump on the campaign trail. He has said he will make the US president "see reason".
But on the matter of children being separated from their migrant parents at the US border, Mr Anaya went further than Mr López Obrador, saying that "it reminds me of what the Nazis did in WWII, it's completely unacceptable".
Mr Meade has also criticised President Trump over the tariffs the US recently imposed on Mexican steel.