Brazil's Supreme Electoral Tribunal has declared far-right congressman Jair Bolsonaro the next president of Latin America's biggest country.
With 96 percent of ballots counted, Bolsonaro has 55.5 percent of the votes. Leftist Fernando Haddad of the Workers' Party (PT) has 44.5 percent.
Voters in Sunday's runoff election apparently looked past warnings that the brash former army captain would erode democracy and embraced a chance for radical change after years of turmoil.
Bolsonaro pledged to reform government finances and reorient diplomatic relations in his first public comments on Sunday after winning the polarizing run-off vote.
Bolsonaro said he would begin a virtuous cycle of lower deficits, shrinking public debts and lower interest rates. He also pledged to align Brazil with more advanced countries that can offer the benefits of trade and technology, reversing what he called a recent political bias in diplomatic relations.
His 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.
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.
His leftist rival Haddad, standing in for the jailed PT founder and former Brazilian President Luiz Inacio Lula da Silva, had been trailing Bolsonaro since the first-round vote three weeks ago.
The last round of opinion surveys on Saturday had showed Haddad narrowing a wide polling gap. Endorsements from leading legal figures in Brazil's unprecedented fight against political corruption also raised hopes among Haddad supporters that he could pull off what would be a stunning upset.
Haddad had reduced Bolsonaro's lead from 12 to 8 percentage points in five days, according to the Ibope polling firm that gave him 46 percent of voter support compared with Bolsonaro's 54 percent. A Datafolha poll also released late Saturday showed Bolsonaro had 55 percent and Haddad 45 percent.
While Haddad had gained traction in the polls, he failed to win the key endorsement of center-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.
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 Brasilia.
— The Associated Press and Reuters