Gustavo Petro, a former member of the M-19 guerrilla movement, has won Colombia's presidency.
He will become the country's first left-wing president and has vowed to bring about profound social and economic change.
Mr Petro beat construction magnate Rodolfo Hernandez with an unexpectedly wide margin of some 720,000 votes. The two had been technically tied in polling ahead of the vote.
Mr Petro, a former mayor of the capital city Bogota and current senator, has pledged to fight inequality with free university education, pension reforms and high taxes on unproductive land. He won with 50.5% of the vote to Mr Hernandez's 47.3%.
Mr Petro's proposals - especially a ban on new oil projects - have startled some investors, though he has promised to respect current contracts.
His victory was likely to cause market jitters until his cabinet is announced, analysts said.
Mr Petro will succeed the deeply unpopular conservative Ivan Duque, who was barred by Colombia's constitution from standing for re-election.
Some of Mr Petro's supporters were dancing in the street near Bogota's largest polling place, despite ongoing rain.

This campaign was Mr Petro's third presidential bid and his victory adds Colombia to a list of Latin American countries that have elected progressives in recent years.
A fragmented congress, where a dozen parties have seats, will act as a check on Mr Petro's proposals, said Daniela Cuellar of FTI Consulting.
"Colombia's institutional strength and rule of law appear sufficiently robust for the country to maintain economic stability," Ms Cuellar said.
"Moreover, campaigning is not governing, Mr Petro's policies will be more moderate.
"Even if he tries to pass radical reforms, he does not have the congressional support to implement them," she added.
Mr Petro, 62, said he was tortured by the military when he was detained for his involvement with the guerrillas, and his potential victory had high-ranking armed forces officials bracing for change.
Mr Petro's running mate Francia Marquez, a single mother and former housekeeper, will be the country's first Afro-Colombian woman vice-president.
Mr Petro has also pledged to fully implement a 2016 peace deal with FARC rebels and seek talks with the still-active ELN guerrillas.
Mr Petro had raised doubts about the integrity of the count after irregularities in congressional tallies in March and earlier yesterday urged voters to check their ballots for any extraneous marks which could invalidate them.
Mr Hernandez, who served as mayor of Bucaramanga, was a surprise contender in the run-off and ran on anti-corruption promises even though he himself is under investigation. He has denied wrongdoing.
Mr Hernandez, who refers to himself as the "king of TikTok", ran a campaign focused on social media, repeatedly cancelling interviews and barely appearing in public in the 10 days prior to the vote.
He conceded defeat in a short video on social media.
"As I said during the campaign, I accept the results of this election," Mr Hernandez said, adding he hopes Mr Petro will be loyal to anti-corruption promises.
Some 22.6 million people voted, about 1.2 million more than in the first round. Some 2.3% of voters turned in protest votes, backing neither candidate.
Market jitters
Analysts have said the proposed halt to oil development could send investment elsewhere at a time when Colombia is struggling with low credit ratings, a large trade deficit and national debt which has doubled to 72% of GDP over the last decade.
Oil accounts for nearly half of exports and close to 10% of national income, but Mr Petro argues new projects should be barred for environmental reasons and to move Colombia away from dependence on the industry.
Mr Petro has also promised to increase taxes and royalties on extractive industries and charge major landholders of unproductive land, raising some €4.9 billion.
He also proposes to raise up to €3.7 billion by progressively taxing companies.
"We think on Tuesday both interest rates on TES bonds and the exchange rate will depreciate, but we need to see what type of rhetoric Petro gives us, what type of cabinet he'll give us," said Sergio Olarte, head economist for Colombia at Scotiabank.