The most-trusted opinion polls had indicated leftist former President Luiz Inacio Lula da Silva was far out front, and potentially even clinching a first-round victory. One prominent pre-election poll gave da Silva a 14 percentage point lead. In the end, Bolsonaro surprised to the upside and came within just 5 points. He will face da Silva in a high-stakes Oct. 30 presidential runoff.
On Sunday, da Silva, known universally as Lula, obtained 48.4% of valid votes, which excludes blank and null ballots, while Bolsonaro got 43.2%, according to Brazil's electoral authority. The first round's nine other candidates received a fraction of the frontrunners' support.
``This is a big defeat for the democratic center that saw its voters migrate to Bolsonaro in a polarized scenario,'' said Arilton Freres, director of Curitiba-based Instituto Opiniao. ``Lula starts ahead, but it won't be easy for him.''
The vote was virtually free from the political violence that many had feared. Alexandre de Moraes, the Supreme Court justice who also leads the electoral authority, congratulated Brazil for the ``safe, calm, harmonious and peaceful'' election that demonstrated its democratic maturity.
Yet tensions remain high, as are the stakes. The election will determine whether the country returns a leftist to the helm of the world's fourth-largest democracy or keeps Bolsonaro in office for another term.
The past four years have been marked by his incendiary speech, testing of democratic institutions, widely criticized handling of the COVID-19 pandemic and the worst deforestation of the Amazon rainforest in 15 years. 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.
``I understand there is a desire from the population for change, but some changes can be for the worse,'' Bolsonaro told reporters after the results were released. Bolsonaro, who has repeatedly claimed without evidence that the nation's electronic voting machines are vulnerable to fraud, didn't challenge the result.
Da Silva is credited with building an extensive social welfare program during his 2003-2010 tenure that helped lift tens of millions into the middle class and saw exports surge amid the global commodities boom. He is also remembered for his political party's involvement in corruption scandals and his own convictions, which were later annulled by the Supreme Court that ruled the judge had been biased. That freed him from imprisonment and cleared the way for his presidential run.
Just ahead of the election, da Silva made a plea for support, saying a small number of votes could mean the difference between an outright victory and a runoff.
Bolsonaro outperformed in Brazil's southeast region, which includes highly populous Sao Paulo, Rio de Janeiro and Minas Gerais states, according to Rafael Cortez, who oversees political risk at consultancy Tendencias Consultoria.
``The polls didn't capture that growth,'' he said. ``It leaves a bitter taste for the left, if we consider what the polls were showing.''
Bolsonaro and allies have repeatedly cast doubt on the reliability of pollsters like Datafolha, and pointed instead to his street rallies with great turnouts. Supporters like retired engineer Ramon Almeida agreed.
``I don't believe these polls by the Datafolha group. I believe the `Data-people' poll I see everywhere Bolsonaro goes,'' Almeida, 72, said Sunday after casting his vote at a school in Sao Paulo's upmarket Pinheiros neighborhood. ``I think there's going to be a runoff in the end.''
Analysts noted that also-rans did worse than anticipated, and their voters appeared to jump ship on the election's eve, decamping to Bolsonaro's side.
``What is most likely is people changed their preferences strategically before the vote, and that really favored Bolsonaro,'' said Nara Pavao, who teaches political science at the Federal University of Pernambuco. ``People who were originally voting for Simone Tebet or Ciro Gomes (the third and fourth place finishers) decided at the last minute to vote for Bolsonaro.''
The difference between Bolsonaro and da Silva in the first round amounted to 6.1 million votes. Tebet and Gomes together earned 8.5 million votes, and more than 30 million people abstained.
Speaking after the results, da Silva betrayed the fact he didn't even know for which date the runoff is scheduled. But he said he was excited for another few weeks of campaigning, and the opportunity to go face-to-face with Bolsonaro and ``make comparisons between the Brazil he built with the Brazil we built during our administrations.''
``During this whole campaign, we were ahead in the opinion polls of all the institutes, even those that didn't want us to win,'' da Silva said. ``I always thought that we were going to win these elections. And I tell you that we are going to win this election. This, for us, is just an extension.''
The right's positive night extended to races for governorships and congressional seats, especially candidates with Bolsonaro's blessing. His former infrastructure minister surprised by finishing first in the race to govern Sao Paulo. The governor of Rio de Janeiro, an ally, vanquished his opponent to win reelection outright.
Sergio Moro, the former judge who temporarily jailed da Silva and was Bolsonaro former justice minister, defied polls to win a Senate seat.
Bolsonaro's Liberal Party will surpass da Silva's Workers' Party to become the biggest in the Senate. In the Lower House, Bolsonaro's Liberal Party and the coalition led by da Silva's Workers' Party will be the chamber's two largest forces.
Among its victors were Bolsonaro's former ministers of regional development and science and technology. In the Lower House, his former health minister, a general who oversaw the pandemic's troubled management, and his former environment minister, who resigned amid an investigation into whether he had aided the export of illegally cut timber in the Amazon, also secured 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.
Bolsonaro told reporters that his party's showing in Congress could bring fresh support ahead of the Oct. 30 vote, as other parties strike alliances in exchange for support in the runoff.
``Brazil is much more polarized than many people thought, and governing will be difficult for whomever wins,'' said Brian Winter, vice president for policy at the Americas Society/Council of the Americas. ``I think the next few weeks will put heavy strain on Brazil's democracy as these two men fight it out. Expect an ugly race that will leave scars.''