RIO DE JANEIRO — Just as many opponents of Donald Trump considered him unelectable in 2016, detractors of Brazil's President-elect Jair Bolsonaro always believed the far-right candidate himself was the ultimate fail-safe mechanism.

Like Trump, who was caught on video boasting that he grabbed women by the genitals, Bolsonaro came to the race with a long history of comments that were offensive to many people. He twice told a female colleague in Congress she was too ugly to be raped, said a dead son was preferable to a gay one and often disparaged blacks and indigenous people.

The former army captain also frequently cast aspersions on democratic institutions and argued that if the 1964-1985 dictatorship made any mistake, it was that it didn't go far enough in killing communists who threatened the nation.

All of that, the reasoning went, made him simply too toxic for the majority in Brazil, a conservative nation but also one where many people pride themselves on a certain live-and-let-live approach to life.

That belief was so strong that parties across the spectrum never considered a unifying strategy against Bolsonaro. Instead, they jockeyed for position, believing that whoever among the other dozen candidates placed second to Bolsonaro in the first round of voting Oct. 7 would beat him in the runoff Sunday.

The left-wing Workers' Party, which had won the previous four presidential elections, was seen as the best positioned to do that despite its problems — the decimation of its ranks and tarnishing of its image by the huge "Operation Car Wash" corruption investigation involving billions of dollars in bribes to politicians via inflated construction contracts.

Jair Bolsonaro and his wife Michelle pose as they arrive to cast their votes in Rio de Janeiro, Brazil, on Sunday. Ricardo Moraes / Reuters

Working on the assumption that a Bolsonaro victory was impossible, the party decided its best shot to get to the second round — and thus to victory — was to rely heavily on its standard bearer, former President Luiz Inacio Lula da Silva, even though he began serving a 12-year sentence for corruption in April.

Though it was clear da Silva's candidacy would eventually be barred, he was adored by enough Brazilians to lead preference polls for over a year. The thinking went that the party could appoint a stand-in at the last minute and da Silva's support would just shift to the new candidate. Enter former Sao Paulo Mayor Fernando Haddad, whose central campaign slogan was "Haddad is Lula, Lula is Haddad."

But at no point did the Workers' Party recognize its role in the "Car Wash" scandal. Nor did the party look beyond da Silva. While he is loved by many, he is also widely loathed because of "Car Wash" and a recession under his successor, President Dilma Rousseff, who was removed from office in 2016 for illegally managing the federal budget.