Far-right populist Jair Bolsonaro won 56 percent of the vote in the run-off against left-wing hopeful Fernando Haddad, official results showed.
Former Army captain Jair Bolsonaro won Brazil's presidential election on Sunday, riding a wave of frustration over corruption and crime that brought a dramatic swing to the right in the world's fourth-largest democracy, official results show.
With 94 percent of the ballots counted, Bolsonaro had 56 percent of the votes in the run-off election against left-wing hopeful Fernando Haddad of the Workers Party (PT), who had 44 percent, according to the electoral authority TSE.
"We cannot continue flirting with communism... We are going to change the destiny of Brazil," Bolsonaro said in an acceptance address in which he vowed to carry out his campaign promises to stamp out corruption after years of leftist rule.
TRT World's Ediz Tiyansan has more from Rio de Janeiro.
The former army captain's rise has been propelled by rejection of the leftist PT that ran Brazil for 13 of the last 15 years and was ousted two years ago in the midst of a deep recession and political graft scandal.
Thousands of Bolsonaro supporters cheered and set off fireworks outside his home in Rio de Janeiro's Barra de Tijuca beachfront neighbourhood as his victory was announced. In Brazil's commercial capital of Sao Paulo, Bolsonaro's win was greeted with fireworks and the honking of car horns.
"Brazil is partying. Brazil's good people are celebrating," said Carmen Flores, local president of Bolsonaro's PSL party.
Meanwhile Bolsonaro's rival Haddad accepted defeat, saying he had a responsibility to join the political opposition.
Laura Chinchilla, the former president of Costa Rica who is head of the Organization of American States' Electoral Observation Mission, said the vote had been calm and orderly across the country, which has suffered a spate of partisan violence during the campaign.
Many Brazilians are concerned that Bolsonaro, an admirer of Brazil's 1964-1985 military dictatorship and a defender of its use of torture on leftist opponents, will trample on human rights, curtail civil liberties and muzzle freedom of speech.
The 63-year-old seven-term congressman has vowed to crack down on crime in Brazil's cities and farm belt by granting police more autonomy to shoot at criminals. He also wants to let more Brazilians buy weapons to fight crime.
Miguel Tinker Salas, a Professor of Latin American Studies at Pomona College, has this analysis from Washington DC.
Bolsonaro greeted by supporters
Polling stations opened at 1100 GMT and the last one closed in far western Brazil at 2200 GMT.
Bolsonaro voted in a military district in Rio de Janeiro, greeted by supporters shouting "legend" and "president."
"The expectation today is the same as I saw in the streets: victory," Bolsonaro said, briefly addressing reporters.
While Haddad has gained traction in the polls, he failed to win the key endorsement of centre-left former candidate Ciro Gomes, a former governor of Ceará state in the northeast, which would have given him a big lift in Brazil's poorest region.
He did win the backing of Rodrigo Janot, Brazil's former prosecutor general under whose watch unprecedented corruption prosecutions took place. Janot tweeted on Saturday that he would vote for Haddad.
Popular anti-corruption judge, Joaquim Barbosa, who jailed several top PT leaders for corruption, also came out for Haddad. The endorsements were a blow to Bolsonaro's campaign to position himself as the anti-corruption candidate.
University student Daniel Castro Correa de Souza, who voted for Gomes in the first round, opted for Haddad on Sunday in an effort to stop Bolsonaro.
"Bolsonaro represents a rupture in democracy, a threat to democracy, because he has authoritarian thoughts. I can't agree with that," said 21-year-old Souza, after casting his vote in the capital Brasilia.