Far-right candidate Jair Bolsonaro has won a sweeping victory in Brazil's presidential election.
Mr Bolsonaro won 55.2% of the votes cast against 44.8% for Fernando Haddad from the left-wing Workers' Party, the Brazilian electoral authority reported.
Mr Bolsonaro campaigned on a promise to eradicate corruption and to drive down Brazil's high crime levels.
The election campaign has been deeply divisive. Each camp argued that victory for the other could destroy Brazil.
What does it mean?
Mr Bolsonaro's victory constitutes a markedly rightwards swing in the largest democracy in Latin America, which was governed by the left-wing Workers' Party for 13 years between 2003 and 2016.
Image copyrightAFP
Image captionSupporters of Fernando Haddad were despondent after the results were announced
For the past two years, the country has been led by a conservative, Michel Temer, following the impeachment of President Dilma Rousseff. But Mr Temer has proven deeply unpopular with Brazilians.
With the outgoing president's approval rating at a record low of 2%, voters clamoured for change but they were deeply divided on which way that change should go.
Mr Bolsonaro's convincing 10-percentage-point victory means the vision he laid out to voters of a Brazil where law and order and family values would be made the priority won out.
Read more:
- What are Bolsonaro's policies?
- The Trump of the Tropics?
- Who supports Bolsonaro?
- Brazil election guide in five charts
What did Bolsonaro say after winning?
He said his government would be a "defender of democracy and the constitution".
"This is not the promise of a party, nor the word of a man. It is an oath before God."
Mr Bolsonaro went on to tell his cheering supporters: "The commitment I assumed with the Brazilian people was to create a decent government, committed to the country and the people. And I guarantee you that I will.
"We will change Brazil's destiny together."
Critics of Mr Bolsonaro are worried that the former army captain, who has expressed nostalgia for the years Brazil was under military rule, may curtail citizens' freedoms and undermine Brazil's constitution.
They are also worried about the rights of minorities following homophobic, racist and misogynistic remarks Mr Bolsonaro made during the campaign and before.
What did Haddad say?
Image copyrightREUTERS
Image captionFernando Haddad said he would fight for those who had not voted for Mr Bolsonaro
Fernando Haddad said he had "a responsibility to join the political opposition" against Mr Bolsonaro and promised to "defend the freedoms of those 45 million people" who voted for him.
He also demanded that the rights of those who had not voted for Mr Bolsonaro be respected.
How did the vote break down?
Mr Haddad won in the north-east of Brazil, the heartland of the Workers' Party and the stronghold of former President Luiz Inácio Lula da Silva, whom Mr Haddad replaced on the Workers' Party ticket after Lula was barred from running due to his corruption conviction.
But Mr Bolsonaro won in all other parts of the country, and in some of them by a very large majority, ultimately giving him a sweeping overall victory.
Presidential Election Results
% valid votes, excluding blank and invalid votes
BRAZIL TOTAL
Counted votes: 99.96%Last update: 21h40 (Brasilia time)
BOLSONARO
55.14%
57,787,869 votes
44.86%
47,022,217 votes
HADDAD
Click on the states for more detailed results
Reset
BOLSONARO
HADDAD
BRAZIL TOTAL
Counted votes: 99.96%Last update: 21h40 (Brasilia time)
-
VALID VOTES
104,989,349 votes
90.43%
-
BLANK VOTES
2,493,109 votes
2.15%
-
INVALID VOTES
8,614,546 votes
7.42%
How did rival supporters react?
There was jubilation in Mr Bolsonaro's camp.
A number of his supporters took to the streets outside his home in Rio de Janeiro to let off fireworks and wave Brazilian flags.
Image copyrightAFP
Image captionMr Bolsonaro's supporters celebrated outside his home
"Brazil is partying. Brazil's good people are celebrating," said Carmen Flores, a local leader of Mr Bolsonaro's PSL party.
"All these people here are outraged, upset about corruption and crime, and we are with Bolsonaro. The people have spoken. For the first time I feel represented," Andre Luiz Lobo, 38, told AFP news agency.
Meanwhile, Mr Haddad's supporters were in a sombre mood.
"I'm surprised Brazilians would vote for hate, for guns," a tearful Flavia Castelhanos in Sao Paulo told AFP.
There were some reports of scuffles between rival supporters.
Uncertain times
Analysis by BBC's Katy Watson in Sao Paulo
Image copyrightEPA
Even before the results came out, Mr Bolsonaro's supporters were dancing for joy - so confident they were of victory.
His promises to get tough on rising crime and his claims of being a clean politician in a country - where many of his rivals have been mired in corruption scandals - have won him millions of admirers.
But his win is going to be a blow for millions.
His links to the military and admiration for the former dictatorship concern many Brazilians, as do his sexist, racist and homophobic remarks.
These are uncertain times, with many worried that - with Mr Bolsonaro in power - the gains made in Brazil since the country returned to democracy 30 years ago could be erased.
What about reaction from outside Brazil?
A number of Latin American leaders congratulated Mr Bolsonaro:
- Argentine President Mauricio Macri described the poll results as Mr Bolsonaro's "triumph"
- Chilean President Sebastián Piñera congratulated Brazilians for a "clean and democratic election"
- Venezuela's Nicolás Maduro said he "extends his congratulations" to the people of Brazil"
And the US president's spokeswoman, Sarah Sanders, said in a statement: "President Trump called President-elect Bolsonaro of Brazil this evening to congratulate him and the Brazilian people on today's elections. Both expressed a strong commitment to work side by side to improve the lives of the people of the United States and Brazil, and as regional leaders of the Americas."
Meanwhile, Amnesty International said that taking into account his campaign pledges, Mr Bolsonaro's victory could pose a "huge risk" to Brazil's indigenous peoples, LGBT communities, black youth, women, activists and civil society organisations.
What is Bolsonaro likely to do once in office?
He takes over from Mr Temer on 1 January 2019.
One of his flagship campaign promises was to increase security for Brazilian citizens. He has portrayed himself as a hardliner who will restore safety to Brazil's streets.
He has indicated that his government will aim to relax laws restricting the ownership and carrying of guns.
His economic policy plans include proposals to reduce government "waste" and promises to reduce state intervention in the economy.
He has suggested that Brazil could pull out of the 2015 Paris Agreement on climate change, arguing that its requirements compromise Brazil's sovereignty over the Amazon region.
Mr Bolsonaro has also said that he will "cleanse" Brazil of corrupt politicians, a campaign promise which was very popular with Brazilians who say they are tired of the corruption which has seen dozens of high-ranking politicians from the established parties jailed.
Latest Stories
-
Hindsight: Dreams fairytale run proved one thing; it is possible
41 mins -
God makes rulers, not you; you can’t choose your successor – Mahama to Akufo-Addo
2 hours -
Contributors own SSNIT, they must decide who becomes its Director-General – Austin Gamey
2 hours -
Move away from theory-based learning towards practical learning approaches – AUCC President to students
3 hours -
Haaland scores as Manchester City beat Nottingham Forest
4 hours -
Villas-Boas elected Porto president
4 hours -
Situation on frontline has worsened, Ukraine army chief says
4 hours -
US doctor describes witnessing starvation in northern Gaza
4 hours -
CAFCC: RS Berkane make final after USM Alger refused to play 2nd leg over Moroccans’ jersey
4 hours -
Elon Musk in China to discuss enabling full self driving
4 hours -
PSG clinch Ligue 1 title after Lyon’s win over Monaco
6 hours -
Guinness Ghana sets the pace at Ghana Beverage Awards with six awards
7 hours -
Burkina Faso suspends BBC, VOA radio broadcasts over killings coverage
7 hours -
Nicole Kidman honoured with AFI Life Achievement Award
7 hours -
Brassier scores winner for Brest as they edge Rennes to secure European football
7 hours