Lula, as he is known, got just over fifty percent of the vote - about one and a half percentage points more than his rival.
Our World News Editor Kate Gregan reports.
An incredible comeback for the former president Lula who - just three years ago - was serving a prison sentence for corruption.
His conviction was later overturned - but these results also highlight a rejection of Bolsonaro’s far-right movement and his divisive four years in office.
Brazil is deeply polarised -- and Lula spoke to that while addressing a crowd of supporters:
"I am here to govern this country in a very difficult situation but I have faith in god that with the help of the people we will find a way out so that this country may live again democratically and harmoniously.
"We can even re-establish peace between families, between divergent opinions, so that we can build the world we need and Brazil."
On the first of January, Lula will take the reins of a country plagued by gross inequality.
The nation is struggling to bounce back from the COVID-19 pandemic.
Nearly 10 million people fell under the poverty line between 2019 and 2021, while literacy and school attendance rates have also fallen.
Mauricio Santoro is a political scientist at Rio de Janeiro University - he told ABC news, the new leader will have a challenging time trying to heal a fractured nation.
"It's going to be difficult for Lula, this contrast between the huge expectations that the Brazilian people are feeling right now and the day-to-day challenge of the government."
Then there's the question of whether Bolsanaro will even accept the results --
Professor Santoro says - probably not.
"He has been talking about how Brazil should not trust the lateral system, how Brazil should not trust the lateral court so probably we are going to face in the next couple of months until Lula's inauguration, the possibility of some sort of violent act from Bolsonaro or his supporters."
Meanwhile, Lula is pledging to improve the life of Brazilians.
He promises to raise the minimum wage each year according to inflation... Invest in education, and vows to end deforestation in the Amazon.
SIGN UP TO OUR NEWSLETTER.
Every Wednesday, we send you an email detailing the biggest and most interesting topics that week. We'll send you the conversations, interviews and perspective-bending opinions that piqued our interest. Sign up below.