Brazil is heading for a presidential run-off after neither of the leading candidates secured more than 50 percent of the vote in the first round of the election.
Right-wing candidate Flávio Bolsonaro will face incumbent President Luiz Inácio Lula da Silva in the second round on October 25.
With 99 percent of the votes counted, Bolsonaro had 47.03 percent, while Lula received 45.16 percent, setting up a closely contested second round.
Bolsonaro, 45, is the eldest son of former Brazilian president Jair Bolsonaro and was endorsed by his father after Jair Bolsonaro was barred from seeking re-election. The former president is serving a 27-year prison sentence over his role in a failed attempt to overturn the previous election result.
Flávio Bolsonaro has pledged to grant his father and supporters convicted over the January 8, 2023 riots an amnesty if he wins the presidency.
The younger Bolsonaro performed better than expected in the first round and has expressed confidence about winning the run-off. His Liberal Party also recorded strong results in the races for governors, senators and federal deputies.
Lula, 80, is seeking a fourth term as president after previously serving from 2003 to 2010 and returning to office in 2023. He narrowly defeated Jair Bolsonaro in the 2022 presidential election.
The campaign has been dominated by issues including the economy, crime, corruption and national sovereignty. Lula has traditionally enjoyed stronger support among poorer voters, women and residents of northeastern Brazil, while Bolsonaro has stronger backing in the south, among wealthier voters and evangelical Christians.
The outcome of the October 25 run-off will determine whether Brazil remains under left-wing leadership or moves towards the right, as several other Latin American countries have done in recent years.