ISTANBUL — Russia’s ambassador to Turkey was assassinated at an Ankara art exhibit on Monday evening by a lone Turkish gunman shouting “God is great!” and “don’t forget Aleppo, don’t forget Syria!” in what Russia called a terrorist attack.

The gunman, who was described by Ankara’s mayor as a policeman, also wounded at least three others in the assault, which was captured on Turkish video. Turkish officials said he was killed by other officers in a shootout.

The assassination instantly vaulted relations between Turkey and Russia to a new level of crisis over the protracted Syria conflict on Turkey’s southern doorstep. It came after days of protests by Turks angry over Russia’s support for Syria’s government in the conflict and the Russian role in the killings and destruction in Aleppo, the northern Syrian city.

Photo
Andrey Karlov, the Russian ambassador to Turkey, speaking at the gallery in Ankara on Monday, moments before he was shot. Credit Burhan Ozbilici/Associated Press

The envoy, Andrey G. Karlov, was shot from behind and immediately fell to the floor while speaking at an exhibition, according to multiple accounts from the scene, the Contemporary Arts Center in the Cankaya area of Ankara.

The gunman, wearing a dark suit and tie, was seen in video footage of the assault shouting in Arabic: “God is great! Those who pledged allegiance to Muhammad for jihad. God is great!”
Then he switched to Turkish and shouted: “Don’t forget Aleppo, don’t forget Syria! Step back! Step back! Only death can take me from here.”

Turkish officials said that the gunman was killed after a shootout with Turkish Special Forces police. The assailant’s identity was not immediately known.

Photo
People huddle during the shooting in the art gallery. Credit Burhan Ozbilici/Associated Press

Russia’s Foreign Ministry spokeswoman, Maria Zakharova, told the Rossiya 24 news channel that Mr. Karlov had died of his wounds in what she described as a terrorist attack.

Russia news agencies said the ambassador’s wife fainted and was hospitalized after learning of her husband’s death. They also said Russian tourists in Turkey had been advised against leaving their hotel rooms or visiting public places as a precaution.

CNN Turk published images showing several people lying on the floor of the gallery.

Russia’s Tass news agency initially quoted witnesses of the attack as saying that there had been an “assassination attempt” against Mr. Karlov, and that he had been shot from behind while finishing his opening remarks at the opening of the exhibition, called “Russia Through Turks’ Eyes.”

While the Russian and Turkish governments back different sides in the Syria conflict, they had been collaborating in recent days in efforts to evacuate civilians from Aleppo.

Photo
The gunman gestures after shooting the Russian ambassador. Credit Burhan Ozbilici/Associated Press

Mr. Karlov, who started his career as a diplomat in 1976, worked extensively in North Korea over two decades, before moving to the region in 2007, according to a biography on the Russian Embassy’s website. He became ambassador in July 2013.
The attack was a rare instance of an assassination of any Russian envoy. Historians said it might have been the first since Pyotr Voykov, a Soviet ambassador to Poland, was shot to death in Warsaw in 1927.

For many Russians, the assassination is likely to recall the 19th-century killing in Tehran of Aleksandr Griboyedov, a poet and diplomat who died after a mob stormed the Russian Embassy. That episode is remembered as the most severe insult to Russia’s diplomatic corps in the country’s history.
More recently, the Lebanese Shiite militia Hezbollah, now allied with Russia in Syria, kidnapped four Soviet diplomats in 1985, killing one and releasing three a month later.

Correction: December 19, 2016
An earlier version of this article misidentified the government that has collaborated with Russia even though it backs a different side in the Syrian conflict. It is Turkey, not Syria.