For a law-and-order obsessive who glories in his military background, Brazil’s far-right presidential candidate Jair Bolsonaro got off to an unlikely start in public life.

He first came to national prominence in 1987 when, still a captain in the army, he was accused of planning a bombing campaign against military bases to protest low salaries. A panel of three colonels investigated and accused him of “conduct contrary to military ethics”. He was later absolved by a higher military court but the accusations ended up working in his favour. A year later, he was elected to the city council in Rio de Janeiro and by 1990 was off to congress in Brasília, representing the interests of Rio’s large military community, both active and retired.

In the 28 years since his arrival in the chamber of deputies, Bolsonaro has eked out a pitiful record as a legislator, getting just two minor laws on to the statute books and never managing to occupy any of the chamber’s offices. When last year he ran to be its president he won the votes of just four out of 513 deputies, less than the number of disciplinary proceedings his distemperate behaviour saw him accumulate over the years.

But despite his undistinguished record, this political outsider is today the far right’s best-ever chance of winning a presidential election in Brazil. With just two weeks to go until the first-round of voting the former parachutist tops all opinion polls even as he recovers in hospital from his stabbing at a campaign rally earlier this month by an apparently psychologically disturbed individual.

His rise reflects the disillusion among voters with Brazil’s traditional political parties. Bolsonaro’s hardline law-and-order message and general distaste for democracy have been a constant feature of his decades on the political fringes. But, aided by his early and skilful co-option of Facebook, Twitter and WhatsApp, he has gained new adherents by tapping into the deep well of anger touched off by public prosecutors who, in 2014, in a series of cases that rocked the country’s political establishment to its core, revealed the true scale of political corruption in the country.

The constant reports of spectacular levels of political graft have bombarded the population just as it suffers through the social pain caused by Brazil’s longest-ever recession. This toxic brew has left over a quarter of the electorate saying they are now willing to take a gamble on transforming a demagogue who for years railed against democracy into their next president.

Supporters of Jair Bolsonaro in front of the Israelita Albert Einstein Hospital, Sao Paulo, after it was announced he had left the intensive care unit. Photograph: Cris Faga/NurPhoto via Getty Images

Right through his public career Bolsonaro has displayed contempt for his country’s democratic and civic norms and the threat of violence against opponents has always been a staple of his rhetoric. At a rally held just days before he was stabbed, he grabbed a camera stand and, simulating a machine gun, said he was going to execute members of his principle political enemy, the left-wing Workers Party.

After years of being viewed as Brasília’s pantomime villain many dismiss such statements as unfortunate figures of speech. But the use of such language in a country that in recent years has become deeply polarised comes with risks. His supporters are widely believed to have been behind a number of gun attacks on Workers Party members in recent months and have been quick to try and blame his stabbing on an international leftist conspiracy, further inflaming the country’s febrile political mood.

He backs the death penalty, wants one of the most lethal police forces in the world to kill more and favours the sterilisation of the poor to combat crime

Having joined the army during the last dictatorship the 63 year old is notorious for his defence of the military regime and its torturers, only criticising it for not having killed 30,000 people instead of the 434 it did murder and disappear. On his office door in Brasília he once pinned up a message for those demanding the military help relatives find the remains of loved ones it had disappeared. “Only dogs look for bones,” it read.

He backs the death penalty, wants one of the most lethal police forces in the world to kill more and favours the sterilisation of the poor to combat crime. In the past he has called for the shutting down of congress and says if he wins next month he will pack the supreme court with his own nominees and turn over half the country’s ministries to the military.

He picked as his running mate Antônio Hamilton Mourão, a former general who before retiring last year warned that if the politicians and judiciary could not resolve Brazil’s crisis “the time will come when we will have to impose a solution”. In a recent speech the general blamed Brazil’s failure to realise its potential in part on “indolence” inherited from its original indigenous inhabitants and the “dishonesty that comes from Africans”, Brazil being the country that imported most slaves into the New World.

Bolsonaro has also trafficked in racism during his career but his deepest contempt seems to be reserved for women and homosexuals. Once asked what he would do if one of his sons dated a black woman or another man he replied: “I don’t run that risk, my sons were very well educated.” In 2011 he told a magazine: “I would be incapable of loving a homosexual son. I would prefer it if one of my sons died in an accident than appear with one of those moustaches.”

Bolsonaro’s support among men is twice that among women

He is also a vocal opponent of equal pay for women, explaining in 2015 that “women should earn a smaller salary because they get pregnant” and has twice got into trouble for telling female colleagues in the congress that he would not rape them because they did not “deserve” it. He once even told an interviewer that after having four sons he had grown weak and so his fifth child ended up being a girl.

Such declarations are defended by Bolsonaro’s supporters as proof of his fearless authenticity and a willingness to confront a supposed culture of political correctness. They also channel a deep vein of machismo in Brazilian society. Bolsonaro’s support among men is twice that among women, and especially strong with wealthy and well-educated ones.

But the controversies his statements create and the further polarisation of society that follows in their wake also serve to distract from facts about his career that clash with the myth dear to his supporters. Despite his claims to be the anti-political candidate who will end Brazil’s culture of corruption Bolsonaro has in fact turned politics into a family industry, with three of his four sons holding elected office. The Bolsonaros have grown rich in the process. According to an analysis by the Valor Econômico newspaper the clan’s wealth increased 276 per cent above the rate of inflation since 2006. He has faced several accusations of corruption of his own and earlier this year it was revealed the woman who looks after the dogs at his summer house was receiving a salary as a member of his parliamentary staff despite no record of her ever doing any work.

More importantly considering the office he is running for, the controversies also serve to draw attention away from the fact that Bolsonaro has no administrative experience and his grasp of the complex issues facing the country has been consistently exposed as limited and simplistic. In a country haunted by endemic violence that last year saw 64,000 people murdered his pledge of a brutal crackdown on crime is a major reason for his popularity. But his solutions to this crisis, among them a plan to liberalise gun laws so “well meaning people” can take on Brazil’s criminals themselves, are dismissed by leading public security experts as dangerous fantasies.

Bolsonaro's rejection rating is the highest of any candidate and especially strong among women and the young

“Bolsonaro says he will resolve the problem of public insecurity but he never details how. Whenever he enters into the specifics of a problem it is clear he has not studied enough. Instead he seeks to exploit people’s emotions,” says Sylvio Costa, director of Congress in Focus, a media outlet that covers Brazil’s legislature. “Few leading experts will be willing to serve in his government because in part they will have no confidence in his technical and political capacity.”

But before he gets to the point of offering out ministries Bolsonaro still must overcome significant hurdles. His rejection rating is the highest of any candidate and especially strong among women and the young. This could prove his undoing if he makes it to a likely run-off round at the end of October between the two best-placed candidates in the first round. His proudly expressed prejudices could yet prevent him reaching the presidency. And his health remains fragile after the stabbing. He will as a result be largely absent from the rest of the campaign, a severe setback for a populist whose appeal is largely invested in his own person rather than any political party or social movement.

But should he manage to overcome all this and climb the ramp to the presidential palace on January 1st, many in Brazil have no doubt about the threat a Bolsonaro presidency would represent to the country’s democratic institutions.

“Bolsonaro uses a rhetoric that constantly defies the rules of the game,” notes Oscar Vilhena Vieira, professor of constitutional law at the Getúlio Vargas Foundation’s law school in São Paulo. “There is no guarantee that this person in power will be someone who will submit himself to these rules, therefore I have no doubt that a victory for Bolsonaro will put the process of democratisation in Brazil – which started back in 1985 – at risk.”

BOLSONARO IN HIS OWN WORDS