RIO DE JANEIRO — Brazil’s top two presidential candidates will face each other in a runoff vote after a close first-round election in which pre-election polls had given leftist former President Luiz Inácio Lula da Silva a commanding lead over farright incumbent President Jair Bolsonaro.

With 98% of the votes tallied in Sunday’s election, Lula da Silva had 48% support and Bolsonaro had 43.6% support. Brazil’s election authority said the result made a second round vote between the two candidates a mathematical certainty.

Nine other candidates were also competing, but their support pales to that for Bolsonaro and da Silva.

The last Datafolha survey published Saturday found a 50% to 36% advantage for da Silva among those who intended to vote. It interviewed 12,800 people, with a margin of error of 2 percentage points.

Bolsonaro outperformed in Brazil’s southeast region, which includes populous Sáo 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,” Cortez said.

Bolsonaro has built a devoted base by defending conservative values, rebuffing political correctness and presenting himself as protecting the nation from leftist policies that he says infringe on personal liberties and produce economic turmoil.

His administration has been marked by incendiary speech, his testing of democratic institutions, his widely criticized handling of the COVID-19 pandemic and the worst deforestation in the Amazon rainforest in 15 years.

Bolsonaro has repeatedly questioned the reliability not just of opinion polls, but also of Brazil’s electronic voting machines. Analysts fear he has lain the groundwork to reject results.

At one point, Bolsonaro claimed to possess evidence of fraud but never presented any, even after the electoral authority set a deadline to do so. He said as recently as Sept. 18 that if he doesn’t win in the first round, something must be “abnormal.”

Da Silva, 76, was once a metalworker who rose from poverty to the presidency and is credited with building an extensive social welfare program during his 2003-2010 tenure that helped lift tens of millions into the middle class.

But he is also remembered for his administration’s involvement in vast corruption scandals that entangled politicians and business executives.

Da Silva’s convictions for corruption and money laundering led to 19 months imprisonment, sidelining him from the 2018 presidential race that polls indicated he had been leading against Bolsonaro. The Supreme Court later annulled da Silva’s convictions on grounds that the judge was biased and colluded with prosecutors.

A slow economic recovery has yet to reach the poor, with 33 million in this country of 217 million people going hungry despite higher welfare payments. Like several of its Latin American neighbors coping with high inflation and a vast number of people excluded from formal employment, Brazil is considering a shift to the political left because it faces a host of challenges, including environmental threats and a deeply polarized population.

Speaking after casting his ballot in Sao Bernardo do Campo, where he was a union leader, da Silva recalled that four years ago he was imprisoned and unable to vote.

Bolsonaro grew up in a lower-middle-class family before joining the army. He turned to politics after being forced out of the military for openly pushing to raise servicemen’s pay. During his seven terms as a fringe lawmaker in Congress’ lower house, he regularly expressed nostalgia for the country’s two-decade military dictatorship.

His overtures to the armed forces have raised concern that his possible rejection of election results could be backed by top brass.

On Saturday, Bolsonaro shared social media posts by right-leaning foreign politicians, including former U.S. President Donald Trump, who called on Brazilians to vote for him.

Israel’s former Prime Minister Benjamin Netanyahu expressed gratitude for stronger bilateral relations and Hungarian Prime Minister Viktor Orbán also praised him.

After voting Sunday morning, Bolsonaro told journalists that “clean elections must be respected” and that the first round would be decisive. Asked if he would respect results, he gave a thumbs up and walked away.

Bolsonaro had claimed for months that the polls were underestimating his support, using his enormous rallies as evidence. Yet, every trusted poll showed him behind. On Sunday, it was clear that he was right. With most of the ballots counted, he performed better in all of Brazil’s 27 states than what Ipec, one of Brazil’s biggest pollsters, had predicted a day before the election.

Pollsters appeared to misjudge the strength of conservative candidates across the country. Governors and lawmakers supported by Bolsonaro also outperformed polls, winning many of their races Sunday.

Cláudio Castro, governor of Rio de Janeiro state, was reelected in a landslide, with 58% of votes, 10 points above of what Ipec predicted.

At least seven former ministers of Bolsonaro’s were also elected to Congress, including his former environment minister, who oversaw skyrocketing deforestation in the Amazon, and his former health minister, who was widely criticized for Brazil’s delay in buying vaccines during the pandemic.

Outside Bolsonaro’s home in a rich, beachside neighborhood in Rio de Janeiro, his supporters gathered to celebrate, dancing and drinking out of plastic cups of beer.

“We expected he would have an advantage of 70%” of the votes, said Silvana Maria Lenzir, 65, a retiree with stickers of Bolsonaro’s face covering her chest.

“Polls do not reflect reality.”

Still, over the next four weeks, Bolsonaro will have to make up ground on da Silva, who was still the leading vote-getter Sunday. Bolsonaro is trying to avoid becoming the first incumbent to lose his reelection bid since the start of Brazil’s modern democracy in 1988.

Includes material from The New York Times