RIO DE JANEIRO – As recently as two months ago, few people in Brazil other than Jair Bolsonaro's most ardent supporters believed the far-right congressman had more than an outside shot of winning the race to lead Latin America's largest nation.
Former President Luiz Inacio Lula da Silva had been ahead in the polls for a year despite a corruption conviction and a jail sentence that began in April.
Even though Bolsonaro always placed second in the polls, his support hovered around 30 percent and analysts said he had likely reached his ceiling. His history of comments offensive to women, blacks and gays, combined with his praise of the 1964-1985 military dictatorship and a largely unremarkable 27 years in Congress created the general impression that, even if he survived the first round of voting, he would ultimately be defeated against almost any competitor in the second round.
But then several things happened that helped elevate the former army captain to front-runner: Bolsonaro got stabbed and nearly died, traditional coalitions on the left and right collapsed and it became apparent that social media had replaced television airtime as the most dominant force in the elections.
Those events arguably deepened Brazilians' hunger for radical change after years of turmoil that provoked rage at the ruling class.
In the first round of voting on Oct. 7, Bolsonaro performed far beyond expectations, nearly winning outright with 46 percent of the vote, compared with 29 percent for Fernando Haddad of the Workers' Party. Polls ahead of Sunday's runoff showed him with 56 percent of voter intentions compared with 42 percent for Haddad.
Through it all, Bolsonaro's simple campaign promises to clean up corruption and confront rising crime with brutal force have resonated with a population hungry for new approaches.
"How did Donald Trump become president in the United States?" said Carlos Manhanelli, political marketing specialist and chairman of the Brazilian Association of Political Consultants. "It's basically the same thing. Bolsonaro is speaking to the minds of voters. He isn't worried about being politically correct."
The expected front against Bolsonaro hasn't just failed to materialize, but instead appears to be going the other way. That was underscored when Senator-elect Cid Gomes, the brother of third-place presidential finisher Ciro Gomes, blasted Workers' Party supporters at a rally in support of Haddad after the first round.
Gomes, a member of the centrist Democratic Labor Party, blamed the Workers' Party for "creating" Bolsonaro because it had been unwilling to admit its role in the so-called "Carwash" corruption scandal, considered by many to be the largest such scheme in world history.
Launched four years ago, the investigation into kickbacks to politicians via inflated construction contracts brought down many of the country's biggest names, including da Silva, who was convicted of trading favors with Grupo OAS for the promise of a beachfront apartment.
"You have to do a 'mea culpa.' You have to ask for forgiveness," Gomes said while the crowd booed. "You have to have some humility and recognize you did a lot crap."
"You are going to lose in an ugly way," he said.
Indeed, the Workers' Party, which governed from 2003 to 2016, never fully admitted mistakes or looked beyond da Silva, whom Brazilians call Lula, as its standard-bearer. Instead, it has argued that da Silva's conviction was part of a conspiracy between right-wing parties and the judicial system to keep him from running.
While the electoral court's decision on Sept. 1 to bar da Silva's candidacy was long expected, the party did not put Haddad forward as his replacement until Sept. 11, less than a month before the first round of voting.
"Haddad should have been introduced much earlier," said Sergio Praca, a political science professor at the Getulio Vargas Foundation think tank, arguing that the relatively unknown candidate had little time to help the party get past the stain of corruption.
On the right, the traditional powerhouse of the Brazilian Social Democracy Party never gained traction. The reasons were twofold: Many party members have been tainted by the corruption scandal and its standard-bearer, former Sao Paulo Gov. Geraldo Alckmin, failed to generate excitement despite having the lion's share of free airtime, awarded based on party representation in Congress.
While all 13 presidential candidates were maneuvering for a final push, the race was upended on Sept. 6, when Bolsonaro was stabbed while campaigning in Juiz de Fora, a small city 125 miles (200 kilometers) Rio de Janeiro.
The man arrested, Adelio Bispo de Oliveira, appears to have acted alone and was mentally ill. According to police, he said he attacked on God's orders.
For Bolsonaro, the near-death experience gave his campaign a huge boost. Although he was hospitalized for three weeks and couldn't campaign in the streets, his ordeal dominated media coverage. That was particularly significant for a candidate who was only allotted a few seconds of free television airtime each day.
Instead of having to debate or defend his ideas, Bolsonaro stayed in his hospital bed and continued to hammer away at his campaign themes via Facebook Lives and Twitter.
His campaign kept all but friendly media companies from visiting him and announced he would skip several debates on doctors' orders. Even after being discharged in late September, Bolsonaro avoided debates during the last month, citing his health.
Haddad tried to shame Bolsonaro into debating, saying he would be willing to meet his rival anywhere. He and supporters also forcefully argued that Bolsonaro represented a clear risk to Brazil's young democracy. But those concerns appear to have been largely drowned out on social media, where Bolsonaro's campaign outmaneuvered Haddad's.
Beyond numerous daily posts and tweets by Bolsonaro and his three older sons, all politicians, the campaign has undertaken a massive effort on messaging service WhatsApp. In recent weeks, Brazilians have been bombarded by messages that extol Bolsonaro and condemn Haddad, often making outrageous claims.
Along the way, Bolsonaro's campaign may have broken campaign finance laws. An investigative report by the daily newspaper Folha de S. Paulo last week alleged that friendly businessmen were bankrolling the WhatsApp effort, leading to an investigation by the electoral court. Bolsonaro has been responding ever since with the kinds of aggressive tweets and videos that thrill supporters.
The newspaper "is Brazil's biggest fake news," Bolsonaro said in a video transmitted Sunday to supporters at a rally. "You guys will not get any more government advertising money. Sold out press, my condolences."
DiLorenzo reported from Sao Paulo.
Follow Peter Prengaman: twitter.com/peterprengaman
Follow Sarah DiLorenzo: twitter.com/sdilorenzo