ISTANBUL — A lone gunman shot Russia’s ambassador to Turkey and at least three others Monday evening at an art center in Ankara, the Turkish capital. Russia’s Foreign Ministry said the envoy had died in a terrorist attack.

The envoy, Andrey G. Karlov, was shot from behind while speaking at an exhibition, according to multiple accounts including one from The Associated Press, which cited one of its photographers, who was at the scene, the Contemporary Arts Center in the Cankaya area of Ankara.

Others said the ambassador immediately fell to the floor and that the gunman was killed after a shootout with Turkish Special Forces police.

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.

CNN Turk published images showing several people lying on the floor of the gallery. The Turkish television news station NTV reported that at least three other people had been wounded.

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 exhibition called “Russia through Turks’ eyes.”

The attack came amid protests in Turkey over Russia’s role in the Syria war. The Russian and Turkish governments, while backing different sides in the conflict, have been collaborating in efforts to evacuate civilians from the ravaged city of Aleppo.

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.