This article is more than
8 year oldThe killer has been identified as Mevlut Mert Aydintas, 22, a member of the Ankara riot police.
The incident happened a day after protests in Turkey over Russian support for Syrian President Bashar al-Assad.
Turkey's President Recep Tayyip Erdogan said the attack was a provocation aimed at hurting ties with Russia.
He spoke to Russian President Vladimir Putin by phone about the attack and, in a video message, said that those who wanted to harm relations between the two countries "would not achieve it".
In televised remarks, Mr Putin said the act was "undoubtedly a provocation aimed at disrupting the normalisation" of bilateral ties and the "peace process in Syria".
While there were protests in recent days about the situation in Aleppo, on a political level the Turkish and Russian governments have been co-operating in the ceasefire operation, the BBC's Turkey correspondent, Mark Lowen, reports.
Before the attack happened, a meeting of the Russian, Turkish and Iranian foreign ministers had been planned in Moscow for Tuesday.
But now it seems the political fight over Syria's future has spilled over into public hatred, our correspondent says.
The attack was swiftly condemned by other countries:
According to Russian TV, the ambassador had been attending a photo exhibition called "Russia as seen by Turks".
Video of the event shows Mr Karlov making a speech when gunshots ring out. Eight bullets are said to have been fired.
The camera pulls back to show a smartly dressed gunman, wearing a suit and tie, waving a pistol and shouting in Arabic and Turkish.
He can be heard yelling "Don't forget about Aleppo, don't forget about Syria" and uses the Arabic phrase "Allahu Akbar" (God is great). He is said to have died in a shootout with police soon afterwards.
Mr Karlov was rushed to hospital, reports said, but his death was later confirmed by the Russian foreign ministry.
Andrei Karlov, 62, was a veteran diplomat who had served as Soviet ambassador to North Korea for much of the 1980s.
After the fall of the USSR in 1991, he had a posting as Russian ambassador to South Korea before returning to the North for five years in 2001.
Taking up the Ankara posting in July 2013, he had to grapple with a major diplomatic crisis last year when a Turkish plane shot down a Russian jet close to the Syrian border.
Demanding a Turkish apology, Moscow imposed damaging sanctions - notably a freeze on charter flights by Russian tourists - and the two countries only recentlymended ties.
Condemning the attack as an act of "terrorism", Russian foreign ministry spokeswoman Maria Zakharova said Turkey had given assurances that there would be a comprehensive investigation, and those responsible would be punished.
"The memory of this outstanding Russian diplomat, a man who did so much to counter terrorism... will remain in our hearts forever," Ms Zakharova said.