Brazilian far-right politician Jair Bolsonaro - a former army colonel who has expressed his admiration for dictatorship, repeatedly denigrated women, gays and minorities and decried "fake news" throughout his campaign for president - looks certain to become the country's new president.
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.
A year ago, Bolsonaro's bid was widely regarded by political veterans in Brasília as fanciful in a nation renowned for the cordiality and warmth of its people. "There's a light at the end of the tunnel".
"We are going to change the direction of Brazil", said Mr Bolsonaro, 63, when he addressed the country via Facebook from his beachfront home in Rio de Janeiro immediately after the result was revealed. In Brazil's commercial capital of Sao Paulo, Bolsonaro's win was greeted with fireworks and the honking of vehicle horns.
"I first want to thank God", Bolsonaro told supporters in a video transmitted from his home in Rio, recounting how he was stabbed while campaigning last month and nearly died.
He said: "In memory of Col Carlos Alberto Brilhante Ustra, the terror of Dilma Rousseff, I vote yes".
"I make you my witnesses that this government will be a defender of the constitution, of democracy and of freedom", Bolsonaro told a crowd of supporters in Rio de Janeiro.
"We are going to think in terms of more Brazil and less Brasilia", he said referring to the nation's capital. Instead, his speech was a promise to resist.
"We have the responsibility to mount an opposition, putting national interests, the interests of the entire Brazilian people, above everything", Haddad said in a speech to supporters.
Since the height of Brazil's commodity-driven boom almost a decade ago, citizens have seen millions of jobs evaporate, queues at hospitals grow and violence explode to the point that more than 60,000 people a year are murdered. "We are here. We are together!"
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.
Polls ahead of Sunday's vote showed Bolsonaro with a 10 percent advantage.
Haddad has taken the opposite tack, promising to double-down on investment in education, health and social programs, arguing that the gains Brazil made in reducing poverty during the boom years have eroded and the poorest are suffering.
Bolsonaro's candidacy raised serious concerns that he would roll back civil rights and weaken institutions in what remains a young democracy. He has also said he would not treat or pay women the same as men.
It's a far cry from 2005, when the region's leftist leaders-Lula, Nestor Kirchner of Argentina, and Hugo Chavez of Venezuela-rejected U.S. President George W. Bush and his free-trade proposal for the region at the Summit of the Americas in Mar del Plata.
After he secured the victory, Bolsonaro's supporters took to the streets to celebrate. He tweeted on Saturday that he would vote for Haddad.
But Mr. Haddad, his replacement, tried to tap into considerable anti-Bolsonaro sentiment but ultimately proved unable to replicate Mr. da Silva's traction and, worse, came to be viewed as a symbol of a corrupt establishment and a party drunk on power. Likewise, former Attorney General Rodrigo Janot, one of the biggest crusaders against corruption in Haddad's Workers' Party in recent years, endorsed Haddad for similar reasons. He had struggled to overcome voters hatred of the Workers Party.
All that helped drive a rally in Brazilian assets over the past few weeks. Haddad has promised a continuation of many progressive policies of his Workers' Party, which governed from 2003 to 2016.
Dozens of politicians and executives have been jailed in the corruption investigation. There were numerous reports of politically motivated violence, especially directed at gay people, whom Bolsonaro has disparaged. President Trump, meanwhile, reportedly called Bolsonaro to congratulate him on his win. "But he is our way to keep the Workers' Party out of office", said Rafaela Rosa, a 32-year-old teacher, after voting Sunday in Sao Paulo.