With more than 99 per cent of the votes were tallied in the runoff vote, da Silva has earned 50.9 per cent votes and Bolsonaro got 49.1 percent votes.
This was the country's closest election in over three decades. Just over 2 million votes separated the two candidates with 99.5 per cent of the vote counted. The previous closest race, in 2014, was decided by a margin of 3.46 million votes.
It is a stunning reversal for da Silva, 77, whose 2018 imprisonment over a corruption scandal sidelined him from the 2018 election that brought Bolsonaro, a defender of conservative social values, to power.
Da Silva’s inauguration is scheduled to take place on January 1, 2023. He last served as president from 2003-2010.
In a speech at a hotel in downtown Sao Paulo, he said, "Today the only winner is the Brazilian people."
“This isn't a victory of mine or the Workers' Party, nor the parties that supported me in campaign. It's the victory of a democratic movement that formed above political parties, personal interests and ideologies so that democracy came out victorious."
Lula has vowed a return to state-driven economic growth and social policies that helped lift millions out of poverty when he was previously president 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.
Who is Lula da Silva?
As per AFP, Lula grew up in deep poverty. He was the seventh of eight children born to a family of illiterate farmers in the arid northeastern state of Pernambuco. When he was seven, his family joined a wave of migration to the industrial heartland of Sao Paulo.
Lula worked as a shoeshine boy and peanut vendor before becoming a metalworker at the tender age of 14. In the 1960s, he lost a finger in a workplace accident. He rose quickly to become head of his trade union, and led major strikes in the 1970s that challenged the then-military dictatorship. In 1980, he co-founded the Workers' Party, standing as its candidate for president nine years later.
Lula lost three presidential bids from 1989 to 1998, finally succeeding in 2002 and again four years later. This was his sixth presidential campaign.
The twice-widowed father of five survived throat cancer and in 2017 lost his wife of four decades, Marisa Leticia Rocco, to a stroke. Lula has said he is again "in love as if I were 20 years old" with Rosangela "Janja" da Silva, a sociologist and PT activist whom he married in May.
Da Silva is credited with building an extensive social welfare programme during his 2003-2010 tenure that helped lift tens of millions into the middle class as well as presiding over an economic boom. The man universally known as Lula left office with an approval rating above 80 per cent; then U.S. President Barack Obama called him “the most popular politician on Earth."
But he is also remembered for his administration’s involvement in vast corruption revealed by sprawling investigations. Da Silva’s arrest in 2018 kept him out of that year’s race against Bolsonaro, a fringe lawmaker at the time who was an outspoken fan of former U.S. President Donald Trump.
Da Silva was jailed for for 580 days for corruption and money laundering. His convictions were later annulled by Brazil’s top court, which ruled the presiding judge had been biased and colluded with prosecutors. That enabled da Silva to run for the nation’s highest office for the sixth time.
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. But he built a devoted base by defending conservative values and presenting himself as protection from leftist policies that he says infringe on personal liberties and produce economic turmoil.
Thomas Traumann, an independent political analyst, compared the results to Biden's 2020 victory, saying da Silva is inheriting an extremely divided nation.
“The huge challenge that Lula has will be to pacify the country," he said. “People are not only polarised on political matters, but also have different values, identity and opinions. What's more, they don't care what the other side's values, identities and opinions are."
Carlos Melo, a political science professor at Insper University in Sao Paulo, compared the likely political climate to that experienced by former President Dilma Rousseff, da Silva’s hand-picked successor after his second term.
“Lula’s victory means Brazil is trying to overcome years of turbulence since the reelection of President Dilma Rousseff in 2014. That election never ended; the opposition asked for a recount, she governed under pressure and was impeached two years later," said Melo. “The divide became huge and then made Bolsonaro."
Congratulations for Lula — and Brazil — began to pour in from around the world Sunday evening, including from US President Joe Biden, who highlighted the country's “free, fair, and credible elections." The European Union also congratulated da Silva in a statement, commending the electoral authority for its effectiveness and transparency throughout the campaign.
(With inputs from agencies)