Brazilians have voted in a highly polarised election that could determine if the country returns a leftist leader to run the world’s fourth-largest democracy or keeps the far-right incumbent in office for another four years.

Anyone at voting stations before the formal closing at 5pm Brasilia time (2000 GMT) was still able to vote, authorities said, and long lines of people waited to cast their ballots in many cities.

The race pits incumbent President Jair Bolsonaro against his political nemesis, former president Luiz Inacio Lula da Silva.

There are nine other candidates, but their support pales in comparison to that for Mr Bolsonaro and Mr da Silva.

Brazil Corruption Crusader
Brazil’s former president Luiz Inacio Lula da Silva shakes hands with a supporter as he campaigns in Sao Paulo ahead of the election (Victor R Caivano/AP)

Recent opinion polls have given Mr da Silva a commanding lead — the last Datafolha survey published on Saturday found that 50% of respondents who intended to vote for a candidate said they would vote for Mr da Silva, compared to 36% for Mr Bolsonaro.

Mr Bolsonaro’s administration has been marked by incendiary speeches, 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 has built a devoted base by defending traditional family values, rebuffing political correctness and presenting himself as protecting the nation from leftist policies that infringe on personal liberties and produce economic turmoil.

President Jair Bolsonaro leads a caravan of motorcycle enthusiasts during a campaign event in Sao Paulo
President Jair Bolsonaro leads a caravan of motorcycle enthusiasts during a campaign event in Sao Paulo (Marcelo Chello/AP)

A slow economic recovery has yet to reach the poor, with 33 million Brazilians going hungry despite higher welfare payments.

Like several of its Latin American neighbours coping with high inflation and a vast number of people excluded from formal employment, Brazil is considering a shift to the political left.

Gustavo Petro in Colombia, Gabriel Boric in Chile and Pedro Castillo in Peru are among the left-leaning leaders in the region to have recently assumed power.

Electoral workers move electronic voting machine boxes at a distribution centre in Rio de Janeiro
Electoral workers move electronic voting machine boxes at a distribution centre in Rio de Janeiro (Matias Delacroix/AP)

There is a chance Mr da Silva could win in the first round, without the need for a run-off on October 30.

For this to happen, he would need more than 50% of valid votes, which exclude spoiled and blank ballots.

Brazil has more than 150 million eligible voters, and voting is mandatory, but abstention rates can reach up to 20%.

An electoral worker installs an electronic voting machine at a polling station in Brasilia
An electoral worker installs an electronic voting machine at a polling station in Brasilia (Eraldo Peres/AP)

An outright win would sharpen focus on Mr Bolsonaro’s reaction to the count, given he has repeatedly questioned the reliability not just of opinion polls but also of the electronic voting machines.

Analysts fear he has laid the groundwork to reject results.

At one point, the president claimed to possess evidence of fraud but failed to present any, even after the electoral authority set a deadline to do so.

Supporters of Mr da Silva dance and sing at a public bar at the Lapa neighbourhood of Rio de Janeiro
Supporters of Mr da Silva dance and sing at a public bar at the Lapa neighbourhood of Rio de Janeiro (Matias Delacroix/AP)

He said as recently as September 18 that if he did not win in the first round, something must be “abnormal”.

Mr da Silva, 76, will vote in Sao Paulo state, where he was once a metalworker and union leader. He rose from poverty to the presidency and is credited with building an extensive social welfare programme during his 2003 to 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.

Supporters of Mr Bolsonaro at a campaign rally in Pocos de Caldas
Supporters of Mr Bolsonaro at a campaign rally in Pocos de Caldas (Andre Penner/AP)

Mr da Silva’s own convictions for corruption and money laundering led to him spending 19 months in prison, sidelining him from the 2018 presidential race that polls indicated he had been leading against Mr Bolsonaro.

The Supreme Court later annulled Mr da Silva’s convictions on the grounds that the judge was biased and had colluded with prosecutors.

Mr Bolsonaro, who will vote in Rio de Janeiro, grew up in a modest family before joining the army. He eventually 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.