Russia’s ambassador to Turkey was fatally shot Monday at an art exhibition by a gunman shouting "God is great!" who continued ranting as the diplomat lay dying on the floor and onlookers ducked for cover.

Andrey Karlov was delivering a speech at a museum in the capital city of Ankara when a man dressed in a suit and tie suddenly appeared and opened fire.

"God is great," he yelled in Arabic. "Those who pledge allegiance to Muhammad for jihad. God is great!"

The gunman, who fired eight shots, also smashed several of the photos at the exhibition, according to an AP photographer who was in the audience.

Switching to Turkish, the gunman then yelled, "Don’t forget Aleppo, don’t forget Syria! Step back! Step back! Only death can take me from here!”

Russian Ambassador to Turkey, Andrei Karlov (R) gives a speech as he visits an art fair in Ankara, Turkey, on Dec.19, 2016. Ecenur Colak / Anadolu Agency Via Getty Images

Turkish police then shot the gunman dead, but not before he wounded three more people, whose conditions were not immediately known.

"The perpetrator has been neutralized," the Turkish Foreign Ministry said in a statement.

Police sources told NBC News the gunman was a 22-year-old officer in the Ankara Special Forces who got into the museum after flashing an ID. He was identified as Mevlut Mert Altintas, an officer who worked with riot police for two and a half years.

Karlov was rushed to a local hospital and a Russian foreign ministry spokeswoman said he was dead. Turkish Prime Minister Binali Yildirim said one of the three wounded visitors was a foreign national, and the inured were being treated.

"Every effort is being made to bring the perpetrators of this heinous terrorist attack and the dark forces behind them into the open and deliver them to justice," Yildirim said.

Russian President Vladimir Putin branded the killing as a "cowardly" attempt to disrupt "the normalization of Russian-Turkish relations" after the Russian Embassy in Washington denounced the "terror attack."

"Andrey was very intelligent, gentle person, kind," he said in a statement. "I know this firsthand, because I know him personally."

'@mfa_russia: We qualify what happened as a terror attack. Turkish authorities are assuring t/ comprehensive investigation will B conducted pic.twitter.com/kqBol0K7QR — Russia in USA (@RusEmbUSA) December 19, 2016

The shooting happened a day before Turkish Foreign Minister Mevlüt Çavuşoğlu was supposed to head to Moscow for talks about the Syrian civil war with Russian and Iranian diplomats — and after several days of protesting by Turks angry over Russia's support for the Syrian government and the destruction of Aleppo.

Turkey's President Tayyip Erdogan called Altintas a "killer" and said Turkey would not be intimidated.

RELATED: Turkey's Erdogan Meets Putin for 'New Page' in Restored Relations

"I'm calling out those who are in the endeavor of this destruction, this expectation of yours will never be achieved and you are wasting your time waiting for it and will waste more time waiting for it," Erdogan said in a speech broadcast by CNN Turk and other outlets.

Relations between Russia and Turkish government have also been tense in recent years over the ongoing bloodshed in Syria. Last year, Moscow cut ties after the Turks shot down a Russian jet on the Syrian border.

An unnamed gunman gestures after shooting the Russian Ambassador to Turkey, Andrei Karlov, at a photo gallery in Ankara, Turkey, on Dec. 19, 2016. Burhan Ozbilici / AP

But in recent months there has been a thaw. Putin personally visited Turkey in October to push for revival of a stalled natural gas pipeline project.

Karlov, who was born in 1954, had been based in Ankara for three years, according to a resume posted on the Russian embassy site. Prior to that, he worked for two decades in North Korea. He was married and had a son.

President Barack Obama, in Hawaii for the holidays, was briefed on the assassination and the White House condemned the Karlov killing.

"This heinous attack on a member of the diplomatic corps is unacceptable, and we stand united with Russia and Turkey in our determination to confront terrorism in all of its forms," the White House said.

Secretary of State John Kerry denounced "this despicable attack," calling it "an assault on the right of all diplomats to safely and securely advance and represent the nations of the world."

Strongly condemn savage attack on #Russia Amb to #Turkey Andrey Karlov & several other ppl. Our thoughts are w/the victims & their families. — Samantha Power (@AmbassadorPower) December 19, 2016

President-elect Donald Trump offered his condolences to Karlov's loved ones and said his killer was a "radical Islamic terrorist."

"The murder of an ambassador is a violation of all rules of civilized order and must be universally condemned," Trump said.

British ambassador to Turkey Richard Moore called Karlov a "quietly spoken, hospitable professional" and said his thoughts were with his wife and family.

Meanwhile, the State Department urged American citizens to steer clear of the embassy in Ankara, which went into lockdown immediately after the shooting. It was lifted later Monday.

Tuesday morning local time, a man was arrested after shots were fired outside the American embassy in Ankara, authorities said.

No one was hurt, a U.S. State Department official told NBC News, and Turkish authorities are investigating. Turkish media reported the man fired a shotgun eight or nine times shortly before 4 a.m. local time.