Jair Bolsonaro (left) and Fernando Haddad will face each other in a run-off. Photo: Reuters
The far-right candidate, Jair Bolsonaro, has won the first round of Brazil's presidential election.
He will face the left-wing Workers' Party candidate, Fernando Haddad, in the second round on 28 October after he failed to win the 50% of valid votes needed to win outright.
With almost all the votes counted, Mr Bolsonaro had 46% and Mr Haddad 29%.
Opinion polls conducted before the election predicted that in a second round the two candidates would be tied.
Mr Bolsonaro said that he was certain that if there had not been "problems" with the electronic voting system used in Brazil, he would have won outright.
"I am certain that if this hadn't happened, we would have known the name of the president of the republic tonight,"
He did not specify what he thought those "problems" were.
Brazil's electoral authorities have said the vote went ahead peacefully and without any major problems.