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.

What has Mr Bolsonaro said?
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.

The choice ahead
Brazilians will have to choose between two very different candidates on 28 October.

Mr Bolsonaro, a Catholic, won the support of many evangelical Christians by saying he would defend traditional family values. He has also won over many Brazilians who think his law-and-order stance will make Brazil safer.

On the eve of Sunday's vote, he said that is government would hand down the tough punishments offenders deserved. He is also in favour of relaxing gun ownership laws and has spoken of torture as a legitimate practice. He also wants to restore the death penalty.

In his victory speech, broadcast live on Facebook and uploaded onto Twitter, he said that were two paths Brazilians could follow.

"[There is] the path of prosperity, liberty. family, on God's side... and the other one is that of Venezuela," he said referring to Brazil's socialist-led neighbour, a country mired in a deep economic and political crisis which has driven more than two million people to leave.

"We can't take another step to the left!" he urged voters. "We can't go fraternising with socialism or communism," he said.

He acknowledged that a lot of criticism had been levelled against him but vowed to "unite the [Brazilian] people".

"Together we will be a great nation," he said.

How did Mr Haddad respond?
Mr Haddad has portrayed himself as a trusted candidate for those who baulk at Mr Bolsonaro's style and rhetoric.

Speaking after he had made it into the second round, he said that he and the Workers' Party would "only use arguments, we don't use any guns".

Referring to Mr Bolsonaro's lead he said that he felt "challenged by the results, which alerts us to the risks Brazilian democracy is facing".

"We need to approach this with a sense of responsibility. We want to unite the democrats of this country, to reduce inequality and to achieve social justice," he told his cheering supporters.

He said he and his party have been presented with "a golden opportunity" by making it into the second