Brazilians 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.
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.