The world’s fourth largest democracy stands on the cusp of a wrenching and potentially illiberal political upheaval with Brazil poised to elect a far-right, pro-gun, dictatorship-praising populist as its president.

Latest polls give Jair Bolsonaro, a former paratrooper known for his venomous rhetoric towards black, gay and indigenous people and women, a 12-point lead over his leftist rival, Fernando Haddad, ahead of Sunday’s election.

“WE’RE GOING TO TURN BRAZIL INTO A GREAT NATION,” Bolsonaro, who styles himself as a tropical Trump – and, like his North American counterpart, favours capitalized tweets – told his 1.9 million Twitter followers ahead of what some call the most important election in Brazilian history.

Polls suggest Haddad, a former mayor of São Paulo, has been chipping away at Bolsonaro’s advantage in recent days, with the Workers’ party (PT) candidate claiming a historic reversal was afoot.

“I’ve got news for you …. we’re going to turn this around,” Haddad tweeted on Thursday night after polls showed him gaining ground with 44% of intended votes compared to Bolsonaro’s 56%.

Writing in the O Globo newspaper, commentator Merval Pereira said the distance between the two men appeared to be closing like “an alligator’s mouth”. That mouth was unlikely to shut completely, “but given how unusual and polarised this election is, nothing is impossible”.

However, Bolsonaro – a deeply divisive figure who survived a near-fatal eve-of-election assassination attempt – remains the overwhelming favourite.

José Roberto de Toledo, a political journalist from the magazine Piauí, said he believed the chances of a Haddad upset were minuscule, pointing out that support for Bolsonaro was stable in Brazil’s south and south-east.

“It’s a new era – I have no doubt about it,” he said of the sweeping political changes a Bolsonaro win is likely to usher in.

The frontrunner paints himself as a Trump-esque political outsider, and on Friday won the endorsement of the US president’s former adviser Steve Bannon, who told Reuters: “Captain Bolsonaro is a Brazilian patriot, and I believe a great leader for his country at this historic moment.”

But Bolsonaro has been a congressman – albeit a peripheral one known largely for his offensive and incendiary remarks – for almost three decades.

Even so, his breakneck rise from political irrelevance to the cusp of leading Latin America’s largest economy has stunned foes and followers alike.

“If you go back a year, did anyone in their right mind expect he would become the next president of Brazil? Absolutely not,” said Scott Mainwaring, a Harvard Kennedy school Brazil expert.

Mainwaring attributed the radical’s rise to the “dramatic failures” of the PT, which ruled Brazil from 2003 to 2016, and the country’s conservative establishment, both discredited by mammoth corruption scandals.

Under PT president Dilma Rousseff, who was impeached in August 2016, Brazil lurched into its worst-ever recession and deeper into a homicide crisis that claimed a record 63,880 lives last year. The party’s most important figure, former president Luiz Inácio Lula da Silva, is currently serving a 12-year sentence for corruption.

Against this backdrop of bloodshed and sleaze, experts believe many voters see Bolsonaro as an urgently needed swamp-drainer, if not a saviour.

“It is a vote against everything and everyone,” said Toledo.

Lilia Schwarcz, a historian and writer, said Bolsonaro had successfully built his campaign on fear: of an imagined communist threat, a supposed moral collapse, and of chronic insecurity that he has promised to combat by loosening gun laws and with an iron-fist.

“Brazilians are voting for a big father and a very severe father” who would guarantee their safety and vanquish corruption, Schwarcz said. “And the price we are going to pay for this is not important.”

Some fear the price for Brazil’s young democracy could be very high indeed.

Over the years Bolsonaro has repeatedly expressed admiration for autocrats including Peru’s Alberto Fujimori, Chile’s Augusto Pinochet and the military men who ruled Brazil from 1964 to 1985. “I’m in favour of a dictatorship,” Bolsonaro, who is expected to stack his administration with retired generals, once told congress.

Last week he vowed to purge “red” opponents while a video emerged in which his son, Eduardo, spoke of sending troops to close Brazil’s supreme court.

“In the best case scenario, democracy will erode some under Bolsonaro,” predicted Mainwaring, the author of a book called Democracies and Dictatorships in Latin America.

“In the worst case scenario you could imagine a very dramatic erosion of democracy - somewhat akin to what has happened in Turkey, in Nicaragua, in Venezuela and, to a lesser degree, in Hungary, Poland, Bolivia and under Rafael Correa also in Ecuador.”

Environmentalists, human rights activists and Brazil’s LGBT community are also aghast at the rise of a politician who has vowed to expel meddling NGOs from Brazil, intensify police repression and who calls himself a “proud” homophobe .

“It’s devastating,” said Priscilla Bertucci, a trans activist in São Paulo who blames Bolsonaro’s hate-filled discourse for a growing wave of anti-LGBT violence across Brazil. “There was already so much homophobia but with his blessing it is getting worse.”

Following Bolsonaro’s first round win last month, many progressives had hoped a pro-democracy, anti-Bolsonaro front would form, uniting moderate political heavyweights from both left and right. But such a coalition has largely failed to materialise.

Schwarcz said she was disappointed at that abdication of responsibility: “I know the anti-PT sentiment is very strong and I also know that the PT, in a sense, deserves some of it. The PT introduced corruption to the heart of the state. The PT has been very vain and hasn’t wanted to create a kind of national coalition.”

“But when you have a second round like this ... you have to [choose sides].”

Livid at the PT and disenchanted with Brazil’s political class as a whole, tens of millions of Brazil’s 147 million voters appear to have chosen Bolsonaro’s.

“98% [of politicians] are untrustworthy,” complained Josias Albuquerque, a 35-year-old taxi driver from the northeastern city of Recife.

“But we’re not going to vote for the fucking PT. No chance … Dilma, Lula – the PT fucked Brazil. Do you understand?”