Former Brazilian President Luis Inacio Lula da Silva on Sunday defeated incumbent Jair Bolsonaro in an election that marked a stunning comeback for the leftist leader and the end of the country's most right-wing government in decades.
Lula had 50.8 percent of votes compared with 49.2 percent for Bolsonaro with 99.1 percent of voting machines counted, which the Supreme Electoral Court said was enough to "mathematically define" the outcome of the race.
The vote was a rebuke for the fiery far-right populism of Bolsonaro, who emerged from the back benches of Congress to forge a novel conservative coalition but lost support as Brazil ran up one of the worst death tolls of the COVID-19 pandemic.
Lula has vowed a return to state-driven economic growth and social policies that helped lift millions out of poverty when he governed Brazil from 2003 to 2010. He also promises to combat destruction of the Amazon rainforest, now at a 15-year high, and make Brazil a leader in global climate talks.
His victory consolidates a new "pink tide" in Latin America, after landmark leftist victories in Colombia and Chile's elections, echoing a regional political shift two decades ago that introduced Lula to the world stage.
A former union leader born into poverty, Lula organized strikes against Brazil's military government in the 1970s. His two-term presidency was marked by a commodity-driven economic boom and he left office with record popularity.
However, his Workers Party was later tarred by a deep recession and a record-breaking corruption scandal that jailed him for 19 months on bribery convictions, which were overturned by the Supreme Court last year.
In his third term, Lula will confront a sluggish economy, tighter budget constraints and a more hostile legislature. Bolsonaro's allies form the largest bloc in Congress after this month's general election revealed the enduring strength of his conservative coalition.
Bolsonaro has repeatedly made baseless claims of electoral fraud and last year openly discussed refusing to accept the results of the vote. Electoral authorities are bracing for him to dispute the outcome, sources told Reuters, including security preparations in case his supporters take to the streets.
Voting is electronic and the results were announced within two hours of polling stations closing at 5pm (local time).
Lula will take office on Jan. 1.