Polarising far-right politician Jair Bolsonaro looked to be the big winner of a first-round presidential election in Brazil on Sunday, according to most complete results -- but a final victory in a run-off to be held in three weeks is far from assured.
The 63-year-old former paratrooper, who has vowed a harsh crackdown on rampant crime, came within spitting distance of winning the presidency outright on Sunday.
He picked up 47 percent of votes, against 28 percent for his nearest rival, leftwing candidate Fernando Haddad, electoral authorities said after counting ballots fro m 93 percent of polling stations.
Had he pocketed more than 50 percent, he would automatically have become the president-elect.
But he faced fierce resistance from a big part of the 147-million strong electorate put off by his denigrating comments against women, the poor, and his unabashed nostalgia for the brutal military dictatorship that ruled Brazil between 1964 and 1985.
Now Bolsonaro and Haddad -- the two top candidates from a field of 13 on Sunday -- will have to duke it out on October 28.
Surveys suggest Bolsonaro currently has a very slight edge for that run-off but the outcome is too close to call as Haddad will likely now pick up substantial support from the other beaten candidates.
Voting on Sunday revealed the deep divisions generated by Bolsonaro and Haddad.
Some voters -- particularly women -- wore "Not Him" slogans to polling stations, declaring their fierce opposition to Bolsonaro.
But supporters, like 53-year-old lawyer Roseli Milhomem in Brasilia, said they backed him because "Brazil wants change."
"We've had enough of corruption. Our country is wealthy, it can't fall into the wrong hands," she said.
Other Brazilians banged pots in protest when Haddad, 55, voted in Sao Paulo, the mega-city he once ruled as mayor.
There is palpable disappointment and anger at the Workers Party, blamed for being at the helm when Brazil plunged into its worst-ever recession, from which it is still struggling to recover.
But a Haddad voter, Jose Dias, said it would be a "catastrophe" if Bolsonaro triumphed.
"A lot of young people are voting for him. They don't know what it was like under the dictatorship," he said.
TRT World's Sandra Gathman has more on the election from Brasilia.
Better-off Brazilians have rallied to Bolsonaro's pledge to crush crime that includes more than 62,000 murders each year, nearly as many rapes and frequent robberies.
Bolsonaro wants to boost police forces and relax gun laws for "good" citizens.
Many voters also like his promises to tackle corruption and cut climbing public debt through privatisations, as well as the devout Catholic's family-first stance.
But poorer Brazilians, who benefited most from the heyday under the Workers Party's iconic former president Luiz Inacio Lula da Silva between 2003 and 2010, want a return to good times and hope Haddad can deliver.
The result is a very split electorate. Whoever ultimately wins will grapple with deep-rooted rejection and a large bloc of ideological hostility.
Despite sitting in congress for nearly three decades, Bolsonaro casts himself as a political outsider in the mold of America's Donald Trump or the Philippines' Rodrigo Duterte: tough talking, brash, promising a root-and-branch overhaul to an electorate weary of traditional parties spouting empty promises.
"We can't always vote for the same candidates, the same parties.
Overall change is needed," a 58-year-old retiree, Rubens Dantas de Oliveira, said as he voted.
In Rio de Janeiro, Clara Gentil turned out to vote in Copacabana, wearing a T-shirt emblazoned with the message "Not him."
"Brazilians were manipulated to vote out of hate. So this election is more important than others. Today, there is recession, hunger, people living in the streets, unemployed," she said.
The outgoing center-right president, Michel Temer -- who took over after Lula's chosen successor Dilma Rousseff was impeached and ousted in 2016 for financial wrongdoing -- was not standing for re-election.
He will leave office at the end of the year as a deeply unpopular figure in a country with 13 million unemployed, climbing public debt and inflation, and record violence.