Gustavo Petro, 51, an anti-corruption champion and rebel in the defunct M-19 movement, won 32 per cent of the vote, with 84 per cent of voting stations reporting on Sunday. His main opponent Enrique Penalosa, the favoured candidate of former President Alvaro Uribe, polled 25 percent and conceded.
Petro, who sought the presidency against Juan Manuel Santos last year, will take office in January. He said his win showed that reconciliation was possible in violence-plagued Colombia.
"Bogota has chosen as its mayor a son of the peace process of 1989," Petro said in his acceptance speech. "Bogota is saying yes to reconciliation, yes to peace."
Petro's election was a setback for Uribe, who left office with a 75 per cent approval rating 14 months ago and since then has been wielding political influence from behind the scenes.
The peaceful voting for local offices nationwide came as a relief after a violent campaign in which 41 of the more than 100,000 candidates were killed. Leftist guerrillas and drug-funded crime gangs have been suspected of the violence, trying to ensure the election of their favorites and control over millions of dollars in oil royalties directed to cities.
The mayor-elect is often cited as an example that Colombia's half century insurgency could end peacefully. The former guerrilla was given amnesty after serving two years in jail for his involvement in the M-19 group.
"Petro downed his weapons and now he is mayor of the most powerful city. It's a very powerful message for the armed left in Colombia. They can be part of the opposition," said Elisabeth Ungar, director of the anti-corruption watchdog Transparency International in Bogota.
Although the M-19 disarmed in the late 1980s, leftist guerrillas of the Revolutionary Armed Forces of Colombia (FARC) remain active and killed 20 army soldiers over two days on 21 to 22 October. Thousands die each year in Colombia's armed conflicts, which are fueled by cash from the illegal narcotics trade.
Petro, an economist, takes over a city in crisis. The last elected mayor, Samuel Moreno, was removed from office and jailed in September on accusations of graft.
While sniffer dogs and bomb squads patrolled the streets, Colombians elected 13,000 posts on town councils and regional governors in the first nationwide vote since Santos, a US ally and former defense minister, took office in August 2010.
The calm voting may help counter concerns that security has eroded since Santos took over from Uribe, whose military offensive pushed back the FARC, reduced kidnappings and homicides and improved the business climate.
Colombia's next presidential poll is in 2014. While Uribe cannot run again, the local election was seen as a gauge of support for Uribe and his clout.
Uribe and Santos, while still allies, have become more distant in recent months as the former strongman uses his Twitter account to criticize Santos and his day-to-day management of the country.
After winning the presidency last year with a record vote tally, Santos quickly passed laws to shore up state finances, distribute oil windfalls more equitably and return land to peasants displaced by decades of conflict.
While his approval rating remains above 70 percent, the Santos government has seen a flare-up in violence from the FARC and other criminal groups.
Local elections tend to be bloody and, in some ways, the fight over resources, the remoteness of many areas and the sheer number of candidates make the poll more important than national elections to the daily lives of many Colombians.