A STEEP hill and a concrete wall divide the worlds of Gabriela Moura, a student from Paraisópolis, a favela in the city of São Paulo, and Roberto Inglese, a lawyer from the prosperous neighbourhood of Morumbi. But on October 7th the two paulistanos were united in their choice for Brazil’s president: Jair Bolsonaro, a far-right former army captain. “All the other politicians are corrupt,” said Mr Inglese, who drove his SUV to vote at a private Italian school. “We need someone with a strong fist against crime,” said Ms Moura, who feared walking to a government-run day-care centre to vote because she had recently been assaulted nearby.

Such sentiments have brought Mr Bolsonaro to the verge of victory in a run-off, to be held on October 28th. He won 46% of the vote in the first round in a crowded field of candidates. His run-off rival is Fernando Haddad of the left-wing Workers’ Party (PT), whose de facto leader is Luiz Inácio Lula da Silva, a former president who is serving a jail sentence for corruption. Mr Haddad enters the second round 17 percentage points behind. Betting markets give Mr Bolsonaro an 85% chance of becoming Brazil’s next president.

That would be an extraordinary response to a series of traumas that have befallen Latin America’s biggest country over the past several years: the worst recession in Brazil’s history; interlocking corruption scandals, known collectively as “Lava Jato” (Car Wash), which implicated all big political parties; and rising levels of violence. The number of murders reached a record of nearly 64,000 last year.

To fix these problems Brazilians are turning to a politician-provocateur more notable for the extremism of his rhetoric than for anything he achieved in seven terms as a congressman. Mr Bolsonaro has insulted women, blacks and gays. He encourages police to kill suspected criminals, and regards the dictators of the 1970s and 1980s as role models (see Bello).

He crushed candidates with more temperate views and more impressive track records, including Geraldo Alckmin, the nominee of the centrist Party of Brazilian Social Democracy (PSDB). A longtime governor of the state of São Paulo with a big electoral coalition, Mr Alckmin had 40 times Mr Bolsonaro’s allocation of free advertising time on television. It did not help. The upstart got more attention on social media and in the news (in part because he was stabbed at a campaign rally in September). For the first time in three decades the PSDB’s candidate failed to win the presidential election or enter the second round.

Almost as startling are the results of the one-round congressional election also held on October 7th. The PSDB lost nearly half its seats in the lower house (see chart). The PT, its longtime rival for national power, will remain a force (probably in opposition) thanks to its strength in the poor north-east. But it lost important races further south. Dilma Rousseff, a Brazilian president who was impeached in 2016, lost her race for a senate seat in Minas Gerais.

Also humbled was the Brazilian Democratic Movement (MDB), the party of the current president, Michel Temer. The president of the senate, Eunício Oliveira, and the party’s chief, Romero Jucá, lost their senate seats. Of 32 senators who ran for re-election, just eight won. In the lower house the re-election rate of deputies dropped from 56% in the previous election to 49%. “It’s the end of a political cycle,” says Luiz Carlos Mendonça de Barros, a former president of Brazil’s development bank.

The incoming congress will suit Mr Bolsonaro, who once called for its temporary closure, better than most analysts had expected. His (misleadingly named) Social Liberal Party (PSL) will be the second-largest in the lower house. Gains for right-leaning parties such as the Brazilian Republican Party (PRB) make the incoming congress the most conservative since the end of the dictatorship in 1985. The centrão, a group of small, ideologically flexible parties that originally backed Mr Alckmin, will help furnish Mr Bolsonaro with a majority for some purposes if he wins the run-off.

It is easier to say what Brazilians rebelled against—the corruption, crime and economic chaos of recent years—than what they voted for. The clearest mandate is for Mr Bolsonaro’s tough-on-crime conservatism. The elections show that the “common man” has conservative attitudes on gay marriage, abortion and the death penalty, says Fernando Schüler, a political scientist at Insper, a university in São Paulo. The “bullet, beef and Bible” parties, strengthened in this election, will back much of Mr Bolsonaro’s agenda if he wins. His plans to loosen gun control and lower the age of criminal responsibility are likely to encounter little congressional resistance. As he reduces environmental protections much of congress may cheer him.

Less certain is whether Mr Bolsonaro will win support for contentious economic reforms. His chief economic adviser, a free-marketeer called Paulo Guedes, wants to reduce pension spending and privatise state-owned companies. Financial markets, rightly worried about Brazil’s public debt, now 84% of GDP, are giddy at the prospect. On the day after Mr Bolsonaro’s near-victory Brazil’s stockmarket rose by nearly 5%.

That looks like overconfidence. The centrão helped vote down a pension-reform proposal put forward by Mr Temer. Some in its ranks back budget-busting subsidies to agriculture and industry. Many new PSL legislators are former military officers and policemen who are protective of their generous pensions. “Society and the markets may be fooled for a while, but it will be surprising if they follow a liberal agenda,” says Marcos Lisboa, Insper’s director.

With 30 parties, the incoming congress is even more fragmented than the current one, which will make it harder to manage. The markets’ enthusiasm for Mr Bolsonaro cooled a bit after he criticised Mr Temer’s pension proposal and after news that Mr Guedes is under investigation for fraud (he denies wrongdoing). Brazil only functions when it has “a president with political experience and aptitude for dialogue”, says Maria Hermínia Tavares de Almeida, a political scientist at the University of São Paulo. Those are not Mr Bolsonaro’s strengths.

With victory in sight, he is playing down his authoritarian impulses. “We will be slaves of the constitution,” he promises, seeking to reassure voters who fear he is plotting to subvert democracy. Some of his supporters are not bothering to hide their nastiness. PSL candidates in Mr Bolsonaro’s home state of Rio de Janeiro who smashed a sign paying tribute to Marielle Franco, a left-wing councilwoman murdered in March, went on to win their races.

Many Brazilians voted for Mr Bolsonaro not because they like him but because they think the PT, which governed when the economy slumped and corruption flourished, is worse. To have any chance of defeating him, Mr Haddad, a former mayor of São Paulo and education minister, must placate those voters while retaining the PT’s core supporters. That will not be easy. Campaign ads that declare “Haddad is Lula” may impress millions of Brazilians who stopped being poor when Lula was president (from 2003 to 2010). But they suggest to others that Mr Haddad would be the puppet of the jailed former president.

The PT has spotted the danger. Lula has disappeared from the campaign’s posters. The candidate, who is more moderate than many of the most influential figures in the PT, has signalled his pragmatism by announcing that he will appoint a businessman to be his finance minister. He has promised a plan to combat crime.

On the eve of the first round he had a lower rejection rate than Mr Bolsonaro: 36% of Brazilians say they would not vote for Mr Haddad under any circumstances, reports IBOPE, a polling firm; 43% say the same of Mr Bolsonaro. That offers only a glimmer of hope. Mr Bolsonaro can win “if he stays quiet”, says Thiago de Aragão of Arko Advice, a consultancy. Mr Haddad must speak loudly—in his own voice.