ANKARA (Reuters) - The Russian ambassador to Turkey was shot in the back and killed as he gave a speech at an Ankara art gallery on Monday by an off-duty police officer who shouted "Don't forget Aleppo" and "Allahu Akbar" as he opened fire.

President Tayyip Erdogan, in a video message to the nation, cast the attack as an attempt to undermine NATO-member Turkey's relations with Russia - ties long tested by the war in Syria. He said he had agreed in a telephone call with Russia's Vladimir Putin to step up cooperation in fighting terrorism.

At a special meeting at the Kremlin, President Putin ordered increased security at all Russian missions and said "the bandits" who committed the act would feel retribution.

"We must know who directed the killer's hand."

The assassination of an ambassador, not least of a major power such as Russia, marks a dangerous escalation of tension in the region and beyond. Security sources said he was off duty and some witnesses said there was no security scanning machine at the entrance.

The attacker was smartly dressed in black suit and tie and stood, alone, behind the ambassador as he began his speech at the art exhibition, 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. People took refuge in adjoining rooms as the shooting continued.

A video showed the attacker shouting: "Don't forget Aleppo, don't forget Syria!" and "Allahu Akbar" ("God is Greatest") as screams rang out. He paced about and shouted as he held the gun in one hand and waved the other in the air.

Russia is an ally of Syrian President Bashar al-Assad and its air strikes helped Syrian forces end rebel resistance last week in the northern city of Aleppo. Turkey, which seeks Assad's ouster, has been repairing ties with Moscow after shooting down a Russian warplane over Syria last year.

The gunman was killed by special forces. Three other people were injured.

"We regard this as a terrorist act," said Russian Foreign Ministry spokeswoman Maria Zakharova. "Terrorism will not win and we will fight against it decisively."

GULEN

Erdogan, who has faced a string of attacks by Islamist and Kurdish militants as well as an attempted coup in July, identified the attacker as 22-year-old Mevlut Mert Altintas, who had worked for Ankara riot police for two and a half years. CNN Turk TV said police had detained his sister and mother.

A senior security official said there were "very strong signs" the gunman belonged to the network of the U.S.-based cleric Fethullah Gulen, who Ankara says orchestrated the failed coup in July. Erdogan has denounced Gulen as a terrorist, but the cleric, a former ally, denies the accusation.

Gulen described the killing as a "heinous act of terror" that pointed to a deterioration of security in Turkey resulting from Erdogan's wide-ranging purge of police as well as the army, judiciary and media following the coup bid.

The government says Gulen, who has lived in self-imposed exile in the U.S. state of Pennsylvania since 1999, created a "parallel network" in the police, military, judiciary and civil service aimed at overthrowing the state.

Suspicion could also fall on a group such as Islamic State, which has carried out a string of bomb attacks in Turkey in the last year as Ankara has pressed a military campaign against the militants in Syria. The group has urged "lone" attacks in the West.

U.S. STATE DEPARTMENT

Turkish Foreign Minister Mevlut Cavusoglu was due to meet his Russian and Iranian counterparts in Russia on Tuesday to discuss the situation in Syria. Officials said the meeting would still go on, despite the attack.

"The attack comes at a bad time: Moscow and Ankara have only recently restored diplomatic ties after Turkey downed a Russian aircraft in November 2015," the Stratfor think-tank said.

"Though the attack will strain relations between the two countries, it is not likely to rupture them altogether."

However, both Russia and Turkey indicated that they were looking to work together to find the combat militant attacks.

The U.S. State Department, involved in diplomatic contacts with Russia in an attempt to resolve a refugee crisis unfolding around the city of Aleppo, condemned the attack, as did the United Nations Security Council.

Tensions have escalated in recent weeks as Russian-backed Syrian forces have fought for control of the eastern part of Aleppo, triggering a stream of refugees.

Turkish police detain six after Russian ambassador shot dead

By Umit Bektas and Orhan Coskun | ANKARATurkish police have detained six people over the killing of the Russian ambassador, state media said, who was shot in the back as he gave a speech in Ankara on Monday by an off-duty police officer shouting "Don't forget Aleppo" and "Allahu Akbar".

The state-run Anadolu agency said on Tuesday the attacker's mother, father, sister and two other relatives were held in the western province of Aydin, while his flatmate in Ankara was also detained.

Police paced up and down behind a cordon on Tuesday morning outside the art gallery where the ambassador, Andrey Karlov, was shot. A crime scene investigation van was parked outside the building.

The United States said its three missions in Turkey would be closed on Tuesday after a gun was fired in front of the U.S. embassy in Ankara overnight. The embassy was near the art gallery where Karlov was shot and Turkish police detained a man over the incident, state media reported.

Russia's foreign ministry said on Tuesday the two countries' foreign ministers had underlined the need to put more effort into effectively fighting terrorism in a phone call overnight.

The Russian, Turkish and Iranian foreign ministers will meet in Moscow later on Tuesday to discuss the crisis in Syria. A Russian delegation was due to arrive in Ankara at 11 a.m. (0800 GMT) to conduct investigations into the attack, broadcaster CNN Turk reported.

SECURITY THREATS

Turkey faces multiple security threats, including from the Islamic State militant group. A spokesman for the hardline Sunni Muslim group urged sympathizers around the world this month to carry out a fresh wave of attacks, singling out Turkish diplomatic, military and financial interests as preferred targets.

However, a senior Turkish security official said there were "very strong signs" the gunman belonged to the network of the U.S.-based cleric Fethullah Gulen, who Ankara says orchestrated a failed coup in July. Erdogan has denounced Gulen as a terrorist, but the cleric, a former ally, denies the accusation, and has also denied any role in the assassination.

A video showed the attacker shouting: "Don't forget Aleppo, don't forget Syria!" and "Allahu Akbar" ("God is Greatest") as screams rang out. He paced about and shouted as he held the gun in one hand and waved his other hand in the air.

Russia is an ally of Syrian President Bashar al-Assad and its air strikes helped Syrian forces end rebel resistance last week in the northern city of Aleppo. Turkey, which seeks Assad's ouster, has been repairing ties with Moscow after shooting down a Russian warplane over Syria last year.