Former left-wing president Luiz Inácio Lula da Silva defeated far-right incumbent Jair Bolsonaro in a photo finish to Brazil’s presidential election late on Sunday night.
Mr Lula was declared winner with 50.8 per cent against 49.2 per cent for Mr Bolsonaro, a margin of just 1.9 million votes out of an electorate of 156 million.
The two candidates had been neck and neck during the count following the bitterest presidential contest since the return of democracy in the 1980s.
Initially behind, when Mr Lula (77) overtook his rival an hour and 45 minutes after polls closed the news was greeted with fireworks in cities across the country.
Brazilian president Lula urges G20 leaders to move faster on net zero climate targets
G20 summit kicks off with global pact to fight hunger and poverty
Alt-right digital influencer loses out by narrow margin in São Paulo mayoral race
Pablo for mayor: A lifestyle coach with no political experience and a criminal past
[ World leaders rush to congratulate Lula on Brazil election victoryOpens in new window ]
The victory completes a remarkable comeback for the former union leader who was excluded from the contest four years ago after being jailed for corruption in a trial that was later annulled after the judge who convicted him was declared to be partial by the Supreme Court.
Election day was marked by accusations of voter suppression after the federal highway police carried out a series of road checks in areas that traditionally vote heavily for Mr Lula.
Mr Bolsonaro has repeatedly threatened not to accept the result if defeated.
Mr Lula became the country’s first working-class president in 2002. He stepped down after two terms in 2010 with approval ratings close to 90 per cent. In 2018, he was jailed on corruption charges and barred from running in that year’s election, which Mr Bolsonaro went on to win.
Mr Lula was freed after 580 days and his convictions quashed on the grounds that he was unfairly tried by Sergio Moro, a rightwing judge who later took a job in Mr Bolsonaro’s cabinet.