Brazil's election board says leftist Luiz Inacio Lula da Silva has won Sunday's presidential runoff election.
The 77-year-old former president beat right-wing incumbent Jair Bolsonaro in a close race.
The board says that with 99.1 percent of the ballots counted, Lula garnered 50.84 percent, compared with Bolsonaro's 49.16 percent.
The election focused on how to rebuild the Brazilian economy, which has been battered by the coronavirus pandemic.
Other issues included protection of the rainforest in the Amazon, which accounts for about 60 percent of the country's land, and steps to fight corruption.
Lula led the country for two terms between 2003 and 2010. He gained support mainly from the poor with a pledge to reduce the wealth gap, which has been exacerbated by the pandemic.
He also stressed the need for stimulus measures to bolster the economy.
Bolsonaro, meanwhile, rallied support from wealthy and conservative citizens.
In South America, leftist governments have taken power in countries such as Peru, Chile and Colombia. Many have sought to distance themselves from the United States.
Lula's victory in Brazil, which has the largest population and economy in South America, is expected to bring changes to the country's relationship with Washington.