Brazilians will head to the polls again for a second round vote after the country's two top presidential candidates both failed to secure enough support for an outright win.
As neither candidate won the majority of support, the race will go to a run-off election on 30 October.
The highly polarised vote will determine whether the country returns a leftist to the helm of the world's fourth-largest democracy or keeps the far-right leader in office for another four years.
Arguably Brazil's most critical election since the end of the military dictatorship in 1985, Mr da Silva of the leftist Workers' Party had 48.26% of the votes in his favour after 99.29% of the total ballots had been counted.
Mr Bolsonaro was in second, with 43.34% support.
Speaking after the first round of the election, Mr da Silva referred to the upcoming run-off as "extra time" in a football game.
"I want to win every election in the first round. But it isn't always possible," he said.
Mr Bolsonaro told reporters in the capital Brasilia that he understood there was "a desire for change" among the population, but that "certain changes can be for the worse".
Recent opinion polls had given Mr da Silva a commanding lead - with a survey on Saturday giving him a 50% to 36% advantage.
But the election wound up being far tighter than anticipated, both in the presidential contest and those for governorships and congressional seats.
"The far-right has shown great resilience in the presidential and in the state races," said Carlos Melo, a political science professor at Insper University in Sao Paulo.
"It is too soon to go too deep, but this election shows Mr Bolsonaro's victory in 2018 was not a hiccup," he added.
Who is Luiz Inacio Lula da Silva?
Mr da Silva, who is affectionately known as Lula, is credited with building an extensive social welfare programme during his 2003-2010 tenure but is also remembered for his administration's involvement in various corruption scandals.
The 76-year-old was jailed in 2018 on corruption charges - but these were later overturned by the Supreme Court.
Some believe the charges were politically motivated, as he was the frontrunner against Mr Bolsonaro in the presidential campaign taking place at the time.
Lula, a former factory worker and union leader, stepped down in 2010 after two terms in office, with approval ratings close to 90% at the time.
During his presidency, deforestation dropped 65% in Brazil, according to Brazil's National Institute for Space Research.
Who is Jair Bolsonaro?
Mr Bolsonaro has been a divisive figure in Brazilian politics since he burst onto the scene over four years ago.
But the 67-year-old'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.
Under President Bolsonaro, farmers and miners have been given free rein to cut down trees at record rates.
However, he has managed to grow a devoted base of supporters by defending conservative values and presenting himself as a protector from leftist policies, which he claims infringe on personal freedoms.
But he has built a devoted base by defending conservative values and presenting himself as protecting the nation from leftist policies that he says infringe on personal liberties and produce economic turmoil.