Brazil voted in deeply divisive presidential elections, with Jair Bolsonaro, a far-right politician vowing a harsh crackdown on crime, seen as the firm favourite in the first round.
Most polling stations closed at 2000 GMT Sunday, with only those in a later timezone in the west of the vast country still open. Initial results were expected later Sunday.
Voting was marked by displays of the polarization generated by Bolsonaro and his nearest rival in a field of 13, leftwing Workers Party candidate Fernando Haddad.
Some voters -- particularly women -- wore "Not Him" slogans to polling stations, declaring their fierce opposition to Bolsonaro, a 63-year-old former paratrooper who has made disparaging remarks of women and gays, and spoken nostalgically of Brazil's 1964-1985 military dictatorship.
But supporters, like 53-year-old lawyer Roseli Milhomem in Brasilia, said they were behind 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.
More From This Section
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.
Polls before the election suggested Bolsonaro could win as much as 43 per cent of valid votes, far ahead of Haddad's 25 per cent.
If no candidate scores more than 50 per cent of ballots, a run-off will be held on October 28. The outcome of that round is far from certain, with Haddad seen as picking up support from many of the other candidates knocked out of the race.
Better-off Brazilians, mainly in the south, have rallied to Bolsonaro's pledge to crush corruption and crime that includes more than 62,000 murders each year, nearly as many rapes and frequent robberies.
They also like his promise to cut climbing public debt through privatizations, as well as the devout Catholic family-first stance.
Bolsonaro wants to boost police forces and relax gun laws for "good" citizens.
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 mould 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.
Bolsonaro said as he voted in Rio de Janeiro he expected to win outright on Sunday, with no need for an October 28 run-off.
"This is going to end today. The 28th we're all going to the beach," he said.
Analysts acknowledged a surge for Bolsonaro in recent days made that scenario possible, though unlikely.
Haddad gambled that the race would go to a run-off, with his odds starkly improved.
That would be "an opportunity for Brazilians to compare the programs," he said as he voted in Sao Paulo.
In Rio de Janeiro, Clara Gentil turned out to vote in Copacabana, wearing a T-shirt emblazoned with the message "Not him," the rallying cry of Bolsonaro's opponents.
"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 centre-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.