Brazilians will head to the polls again on 30 October for a second round vote after former president Luiz Inacio Lula da Silva secured more than a 4% win over incumbent Jair Bolsonaro but failed to get more than 50% of the vote.
The highly polarised run-off election will determine whether the country returns a leftist to the helm of the world’s fourth-largest democracy or keeps the far-right leader in office for another four years.
Arguably Brazil’s most critical election since the end of military dictatorship in 1985, Mr da Silva of the leftist Workers’ Party had 48.07% of the votes in his favour after 98.35% of the total ballots had been counted.
Mr Bolsonaro was in second, with 43.5% support.
Recent opinion polls had given Mr da Silva a commanding lead – with a survey on Saturday giving him a 50% to 36% advantage.
But the election wound up being far tighter than anticipated, both in the presidential contest and those for governorships and congressional seats.
Mr da Silva, who is affectionately known as Lula, is credited with building an extensive social welfare programme during his 2003-2010 tenure, but is also remembered for his administration’s involvement in various corruption scandals.
The 76-year-old was jailed in 2018 on corruption charges – but these were later overturned by the Supreme Court.
Some believe the charges were politically motivated, as he was the frontrunner against Mr Bolsonaro in the presidential campaign taking place at the time.
Mr Bolsonaro’s administration has been marked by incendiary speech, his testing of democratic institutions, his widely criticised handling of the COVID-19 pandemic and the worst deforestation in the Amazon rainforest in 15 years.
However, he has managed to grow a devoted base of supporters by defending conservative values and presenting himself as a protector from leftist policies, he claims infringe on personal freedoms.
But he has built a devoted base by defending conservative values and presenting himself as protecting the nation from leftist policies that he says infringe on personal liberties and produce economic turmoil.
“The far-right has shown great resilience in the presidential and in the state races,” said Carlos Melo, a political science professor at Insper University in Sao Paulo.
“It is too soon to go too deep, but this election shows Mr Bolsonaro’s victory in 2018 was not a hiccup,” he added.