Brazilians are going to the polls to vote in the most polarised presidential election for many years.
Nearly 150 million people are eligible to vote. If no candidate gets more than 50% of the valid ballots, there will be a second round in three weeks.
Far-right candidate Jair Bolsonaro is the frontrunner. He has vowed to tackle crime and record-high murder rates.
His main rival is the left-wing candidate for the Workers’ Party, Fernando Haddad.
A former mayor of São Paulo, Mr Haddad is backed by former President Luiz Inácio Lula da Silva, who was disqualified from standing in the election after he was jailed for corruption.
- Brazil elections: Five things you need to know
- Voters in Brazil debate the merits of democracy
People will also cast ballots to elect all Brazil’s state governors as well as two-thirds of the senators and all lawmakers in the chamber of deputies.
More than 1,000 seats in state legislatures across the country are also being contested.
Mr Bolsonaro has missed the final part of the electoral campaign, after being stabbed at a campaign rally in September.
On the eve of Sunday’s vote, he said his government would hand down the tough punishments offenders deserved. He is in favour of relaxing gun ownership laws and has spoken of torture as a legitimate practice. He also wants to restore the death penalty.
“We need to be really tough on crime to make criminals understand that they won’t enjoy impunity,” wrote Mr Bolsonaro on Twitter.
Mr Haddad tweeted: “I don’t believe in violence, in military dictatorship or the lack of liberty.”
The latest opinion polls suggest about 38% of the electorate will vote for Mr Bolsonaro.
Both he and Mr Haddad are expected to advance to the second-round run-off on 28 October.
Lula left office in 2011 with high approval rates. He was jailed earlier this year for taking bribes from a construction company. He denies the allegations and says they were fabricated to prevent him from running for office again.
- Brazil’s Lula: Saint or sinner?
In a letter of support to Mr Haddad on the eve of the vote, Lula wrote: “Hope has previously beaten fear. Love has beaten hatred. And truth will now beat the lies. Truth is now called Haddad.”
Hundreds of women marched through the streets of São Paulo on Saturday, accusing Mr Bolsonaro of being sexist, racist and a homophobe.
Mr Bolsonaro has rejected the accusations.