In Brazil, the far-right leader Jair Bolsonaro has been defeated by left-wing ex-President Luiz Inácio "Lula" da Silva in the deciding round of Brazil’s presidential vote.
Lula won 50.8% of all valid votes to nearly 49.2% for Bolsonaro.
Lula, president from 2003 to 2010, sought a political comeback after being embroiled in several corruption scandals.
Brazil's Former President Luiz Inácio 'Lula' da Silva won the run-off of the presidential election and incumbent far-right President Jair Bolsonaro failed to win a second term in power.
Lula won 50.83% of all valid votes, whilst 49.17% of votes went to Bolsonaro, with just under 99% of the votes counted at 22:59 GMT.
The new president will be sworn in on 1 January 2023.
Bolsonaro's critics accused him of mishandling the Covid pandemic and allowing rampant deforestation in the Amazon.
The two candidates are polar opposites; Lula is a left-wing former trade union leader and Bolsonaro is a right-wing populist and former army captain.
Political tensions were high in the run-up to the vote, with accusations and misinformation on both sides of the campaign trail.
The votes were extremely close, with no clear winner up until near 99% of all valid votes were counted.
As a politically divided country elects its new president, many have reacted with glee -and some with sorrow.
Who is Luiz Inácio Lula da Silva?
It has been 20 years since Lula won the presidency for the first time.
A former metal worker and union leader, he became a familiar face during the strikes of the 1970s, when workers called for higher wages, defying Brazil's military rulers. He came to power promising change.
Helped by high commodity prices, he spent the windfalls on areas such as higher education and welfare programmes that contributed to lifting millions of Brazilians out of poverty.
In recent years, his legacy was tainted when his party - and Lula himself - was linked to corruption scandals. In 2017, he was sentenced to nine years in prison.
His convictions were annulled four years later, but his brush with the law means that many millions of Brazilians see him as a corrupt politician unfit for office.
The overwhelming reaction among Lula voters here in Rio is one of relief.
While opinion polls had predicted a Lula win from the start, many had lost confidence in them after Lula's advantage in the first round had been much slimmer than expected.
Lula supporters in this bar are not kidding themselves, though.
"We solved our first problem," one of them told me.
"Now we're going to celebrate and then we'll tackle the next one," he said referring to the healing of a divided nation
Lula tweets moments before election officially called
And just a couple of minutes ago, Lula posted a picture of his hand over the Brazilian flag on his Twitter with the caption: "Democracy."
Democracia. pic.twitter.com/zvnBbnQ3HG— Lula (@LulaOficial) October 30, 2022