Barring an unprecedented upset, the far-right candidate Jair Bolsonaro will be elected president of Brazil this Sunday with a comfortable margin over his runoff opponent, the Workers’ Party’s (PT) Fernando Haddad. This will crown a stunning run by the first-time candidate that saw his party, the formerly minuscule Social Liberal Party (PSL), jump from one to 52 federal representatives, propel a number of unknowns to success in the gubernatorial elections and place allies and relatives of Bolsonaro among the most voted across the country.

So how did a candidate with a well-documented history of openly anti-democratic, racist, misogynistic, homophobic remarks, with very little by way of specified policies other than the promise of being a law-and-order hardman who will “banish the reds” and stop the country’s “moral degradation”, come to sweep the board like that?

These were always going to be the most anti-systemic elections in Brazilian history. Since 2013, the country’s political system has been haemorrhaging legitimacy owing to widely perceived lack of accountability, a crippling economic crisis and an endlessly ramifying corruption scandal involving all major parties. A series of desperate attempts have been made to protect the establishment and steady the boat, not least throwing former president Dilma Rousseff overboard in a highly dubious impeachment. They have only managed to create more instability and fragilise institutions even further – not least the judiciary, whose erratic interventions have made it look partisan and weak at once.

It is ironic that Bolsonaro, a member of parliament for 27 years, who has been named in corruption investigations and is supported by some of the shiftiest sectors of Brazilian politics, could successfully present himself as the anti-systemic candidate. In order to understand his rise, we need to look beyond PT’s undeniable mistakes to how the centre right, in its reckless efforts to create instability and exploit institutional meltdown, has endangered the country’s democracy and paved the way for the far right.

In 1994, the Brazilian party system hit upon a formula. While the bulk of it remained an amorphous mass of less than public interests, low on ideological commitment but with very expensive habits, two parties had the cadre, ideas and prestige to marshal this gelatinous blob into opposing blocs: the Workers’ Party on the centre left and the Social Democrats (PSDB) on the centre right. Elections were fought between the armies regimented by the two; whoever won took most of the other’s side as spoil.

The seeds of the far right’s rise started to be sown in the early 2000s, when PT rode the global commodity boom to promote an economic bonanza that raised the standards of living for the poorest while also benefiting the rich. Lula’s success made it impossible for opponents to claim that PT wasn’t working; the country was unequivocally better off than it had been under PSDB. The only available route of attack lay in exploiting moral concerns around elements of PT’s agenda, like women’s and LGBT rights, and reheated Cold War “red scares”. In this, the centre right had support from major media groups and political leaders from the growing Brazilian Pentecostal community, whose electoral profile is essentially tied to moral issues. The more immoderate elements of this tacit alliance were increasingly brought into an echo chamber in which paranoid claims and bogus accusations would be dignified with comments by opposition politicians and media pundits, and thus fed back into a few news cycles until everyone moved on to the next fabricated outrage. An editorial market for anachronistic anti-communist propaganda boomed. Inevitably, this opened the door of mainstream debate, and of centre right parties themselves, to the far right.

PT, in turn, invariably chose negotiation over conflict, trusting that its popular support would always allow it to buy adversaries off and prevent PSDB from reconstituting its bloc. This meant avoiding direct confrontation with the media, a highly unregulated sector that PT had always vowed to democratise, and building an alliance with the Pentecostal right, which included watering down its own progressive agenda. This, of course, only furthered the far right’s mainstream penetration.

Things changed in 2005, when a scheme of parliamentary bribes opened a new line of attack: the message now was that PT was “the most corrupt party of all times” – a tough bar to clear in Brazilian politics. Centre-right leaders believed that letting the scandal run its course would return them to office in 2006, but they were wrong. Lula recovered, won re-election and elected his successor, Rousseff, twice.

After the Petrobras scandal broke in 2014, however, with the economy already in a tailspin and dissatisfaction with the political class as a whole on the rise, PT was against the ropes like never before. This is why, in 2016, PSDB decided not to run the risk of allowing another comeback. Rather than wait for the elections, they joined a rising hard right and PT’s coalition partner, MDB, in a parliamentary manoeuvre to oust president Rousseff. Among those in the political, business and media establishment who supported the move, the calculation was obvious: having led the opposition for 13 years, and having come close to winning in 2014, PSDB was a shoo-in for the 2018 race.

Except they were wrong again. First, they mistook the rising anti-systemic sentiment for a rejection of PT only. Secondly, they failed to consider how much that sentiment would be compounded by the sorry spectacle of the impeachment itself, and the nature of the government it put in place – which passed a number of draconian austerity measures and had a cabinet like a corruption all-star team. So unpopular was it, in fact, that it ended up being a boost to PT, which recovered some of its support in the comparison. This was, in fact, the reason why Lula’s trial was fast-tracked – the establishment’s assumption again being that, with the former president out of the race, the PSDB candidate would have an easy ride. Fatefully, it was also what triggered PT’s decision to field a candidate rather than support one from a less rejected centre-left party.

What the centre right did not realise was that they were no longer driving in the right lane on their own: they were now competing with a force much better positioned to not only ride the anti-systemic tide, but to reap a number of seeds that they had sown.

The anti-corruption campaign that led to Rousseff’s downfall had turned against key MDB and PSDB figures; both parties have lost almost half their seats in parliament. The style of agitation fostered in the early 2000s, based on moral panics and “red scares”, had developed a life on its own on the internet and on WhatsApp groups. Whereas the procedure in the past was for media pundits and politicians to lend these stories a measure of respectability, these figures of authority themselves had now become targets. It is not uncommon to see people justify their vote for Bolsonaro with the fear of a communist dictatorship or that public schools are turning children gay, and to accuse the whole establishment of being in on the plot. Meanwhile, the Pentecostal right has rallied behind Bolsonaro, and Record, a media conglomerate owned by one of the country’s biggest evangelical churches, is angling to be to him what Fox is to Donald Trump. Ironic, no doubt, when one remembers how much Globo, the country’s biggest media corporation since the 1960s, actively supported Rousseff’s impeachment and minimised the anti-Bolsonaro protests that swept the country before the first round of the elections.

In the end, no amount of judicial interventions and open support from financial markets could do the trick: PSDB’s Geraldo Alckmin took less than five percent of the vote. The party, whose founders came out of the struggle against the military dictatorship, has declared neutrality in the runoff, as have most others, despite the many worrying antidemocratic signs coming from Bolsonaro and his camp.

A Bolsonaro government will be a recomposition of the country’s elite, bringing formerly bit-part players centre stage, but certainly not the clean break his voters imagine. It will continue the socially regressive policies of the outgoing Temer government, hitting the poor hard and stifling social mobility for a generation. The realities of building a parliamentary majority will no doubt contradict his anti-corruption discourse. It is unclear how long Bolsonaro will manage to be all things to all people, which raises fears that he might amplify the more belligerent and autocratic elements of his persona as compensation. There have been several cases of violence against journalists, LGBT people and left-wing supporters since the election’s first round, and Bolsonaro’s discourse continues to court political violence explicitly.

As for the political and economic establishment, which until now had in PSDB their natural representatives, it has largely signalled that it is prepared to roll with the new times. Markets have been elated since Bolsonaro took the lead; industrialists have started flocking to him. When a case of electoral fraud with the potential to annul the elections emerged – businessmen had been paying for bulk “fake news” messages supporting Bolsonaro on WhatsApp – most of the media and the electoral court dealt with the case in cool, muted terms. This only strengthened the impression that the same forces that moved to impeach Rousseff have made already made their choice.

The assumption is clearly that Bolsonaro will be willing to outsource key areas of policy to them and that his antidemocratic tendencies can be controlled; that trying to tame his disruption is better than risking another centre-left comeback. A dangerous gamble, no doubt, considering both who the candidate is and the fact that it was exactly that kind of logic that brought them, and the country, to this situation.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial stance.