The Russian ambassador to Turkey was shot dead mid-speech at an art gallery in the capital Ankara on Monday by a gunman shouting "Don't forget Aleppo! Don't forget Syria!"

Andrey Karlov, 62, was several minutes into a speech at the embassy-sponsored photo exhibition, when a smartly dressed man wearing a black suit and tie shouted "Allahu Akbar" (Arabic for "God is great") and fired at least eight shots, according an Associated Press photographer.

Turkish police fatally shot the gunman, who Reuters sources say was an off-duty police officer who worked in Ankara. According to Turkey's interior minister, the gunman was 22 and had been a riot police officer in the city for the past two years.

The gunman, identified as Mevlut Mert Altintas, was killed after a 15-minute shootout with police.

Attacker was pacing and shouting

The attacker was standing behind the ambassador as he made his speech, a person at the scene told Reuters.

"He took out his gun and shot the ambassador from behind. We saw him lying on the floor, and then we ran out," said the witness, who asked not to be identified.

The attacker also said some words in Russian and smashed several of the photos hung for the exhibition.

WARNING: The video below contains graphic content. 

Video of gunman moments after shooting of Russian ambassador to Turkey0:18

A video showed the attacker after he opened fire, shouting: "Don't forget Aleppo! Don't forget Syria!" As screams rang out, he could be seen pacing about and shouting as he held the gun in one hand and waved the other in the air.

The man then yelled: "Stand back! Stand back! Only death will take me out of here. Anyone who has a role in this oppression will die one by one."

Three other people were wounded, Turkish broadcaster NTV reported.

Hours later, the foreign ministers of Russia and Turkey released a statement underlining the need to put more effort into effectively fighting terrorism, the Russian foreign ministry said.

Sergei Lavrov and Mevlut Cavusgolu stressed the need to exclude the possibility of provocations aimed at undermining bilateral relations, as well their cooperation in fighting militants in Syria and Iraq.

Cavusgolu will visit Moscow later Tuesday for a previously scheduled meeting with his Russian and Iranian counterparts to discuss the crisis in Syria.

Lavrov said in a subsequent statement: "We will take measures at this meeting that will make it impossible for those who nurtured the people who ordered and organized this crime to realise their plans."

Turkey Russian Ambasador

A man identified as Mevlut Mert Altintas gestures after shooting the Russia's ambassador to Turkey. Altintas was later killed after a 15-minute shootout with police. (Burhan Ozbilici/Associated Press)

Putin, Erdogan call killing a 'provocation'

Turkish President Tayyip Erdogan spoke by phone with Russian President Vladimir Putin on Monday to share information about the shooting.

Putin, speaking in televised remarks during a meeting with senior officials, said that the killing of Karlov was a "provocation aimed at derailing Russia-Turkey ties and the peace process in Syria."

Erdogan, in a video message being shown on several Turkish TV channels, also said that "this is a provocation to damage the normalization process of Turkish-Russian relations. But both the Russian and Turkish administrations have the determination not to fall for this provocation."

Both leaders said that Russian investigators will be part of the official probe into the killing.

Russia and Turkey have been involved in the almost six-year-long conflict in Syria. Turkey, where two million refugees from Syria have settled, has been a staunch opponent of President Bashar al-Assad while Russia has deployed troops and its air force in support of the Syrian leader.

Turkey Russian Ambassador

A child is held after Karlov was shot at a photo gallery in Ankara on Monday. (Burhan Ozbilici/Associated Press)

'Despicable attack' condemned

"There can be no justification for an attack on an ambassador … and we very much hope that the perpetrators will be brought to justice," UN spokesman Stephane Dujarric said.

Ankara Mayor Melih Gokcek told reporters outside the exhibition centre that the "heinous" attack aimed to disrupt newly re-established relations between Turkey and Russia.

Canadian Prime Minister Justin Trudeau said Karlov's assassination is "something of concern for the entire diplomatic community."

He said he condemned such violence and said his thoughts went out to the Russian people and Karlov's family.

Foreign Affairs Minister Stéphane Dion on Twitter said Canada "condemns in the strongest possible terms" the attack. He offered his condolences to Karlov's family and the Russian people in a series of tweets.

In a written statement, U.S. president-elect Donald Trump called the killing a "violation of all rules of civilized order" and said it must be "universally condemned."

U.S. closes embassies after separate incident

Trump called the gunman a "radical Islamic terrorist" and extended his condolences to Karlov's family and loved ones.

U.S. Secretary of State John Kerry called the killing a "despicable attack" and "an assault on the right of all diplomats to safely and securely advance and represent their nations around the world."

The U.S. is ready to offer help to Russia and Turkey in the investigation of the attack, he said.

Karlov joined the diplomatic service in 1976. He served as Russia's ambassador to Pyongyang, North Korea, from 2001 to 2006 and later worked as the chief of the Russian foreign ministry's consular department. He had served as the ambassador to Turkey since 2013.

Hours after the deadly gallery attack, Turkish police detained a man who fired shots in front of the U.S. embassy in Ankara.

The state-run Anadolu Agency says the man took out a pump action shotgun he hid in his coat and fired around eight shots in the air early Tuesday. He was overpowered by the embassy's security guards.

No one was hurt in the incident.

The embassy said its missions in Ankara, Istanbul and the southern city of Adana would be "closed for normal operations on Tuesday."

With files from Associated Press and CBC News