MOSCOW -  Russian President Vladimir Putin on Tuesday ordered his secret services to boost security at home and abroad after the killing of Moscow's envoy in Ankara and an attack on a Christmas market in Berlin.

"I ask the special services to take additional measures to ensure security inside Russia and outside, to raise the security of Russian institutions and employees abroad," Russian news wires quoted Putin as saying to security bosses, adding they should "strengthen their work" with intelligence agencies from other countries.

A team of Russian investigators arrived in Turkey on Tuesday to probe the assassination of Moscow's ambassador in an Ankara art gallery, as both sides pledged the murder would not damage improving relations. Veteran diplomat Andrei Karlov was shot nine times in the back by off-duty Turkish policeman Mevlut Mert Altintas at the opening of an exhibition of Russian photography on Monday.

The brazen killing stunned Ankara and Moscow, which have rowed repeatedly over the Syria conflict but in recent weeks have begun cooperating closely on the evacuations from war-wrecked Aleppo.

An unprecedented three-way meeting on Syria between the foreign ministers of Turkey, Russia and Iran went ahead in Moscow Tuesday despite the assassination, with the diplomats backing a widening of a truce.

Six people have been detained over the Karlov assassination, including the sister, mother, father and uncle of the 22-year-old Altintas, Turkish media said.

Adding to the jitters, with Turkey already on high alert after a string of deadly attacks, an individual also fired outside the US embassy in Ankara overnight.

In response to the killing, Russian President Vladimir Putin on Monday ordered his top diplomat and spy chiefs to look into boosting security at Russian diplomatic missions around the globe.

Turkish Foreign Minister Mevlut Cavusoglu on Tuesday blamed the group of exiled Turkish cleric Fethullah Gulen for the assassination of Russia’s ambassador in Ankara, the state-run Anadolu news agency said.

In an interview with US Secretary of State John Kerry, Cavusoglu said “Turkey and Russia know that behind the attack... there is FETO,” it said, referring to Turkey’s acronym for Gulen’s organisation. Gulen - an exile accused of orchestrating an abortive coup in Turkey in July - had earlier condemned the assassination as a “terrorist act” that left him “shocked and deeply saddened.”

The United States embassy in Ankara and its consulates in Istanbul and Adana will be closed for normal operations on Tuesday after an individual approached the embassy and discharged a firearm, the embassy said.

It said the individual, who opened fire at 3:50 am (0050 GMT), was in police custody and there were no reported injuries in the incident which occurred hours after Russia's ambassador was shot dead nearby by an off-duty policeman.  The Iranian embassy in Ankara announced that its consulates in the three Turkish cities of Istanbul, Trabzon and Erzurum will be closed on Tuesday after the Russian envoy's killing.

"All consular services in Iranian consulates in Istanbul, Trabzon and Erzurum will be closed on Tuesday, December 20. We urge all Iranians to avoid visiting these locations," the embassy said in a statement on its website. A Russian investigative team visited the scene of the attack at the Contemporary Arts Centre in central Ankara on Tuesday as part of a joint probe with Turkey. Erdogan said in a speech in Istanbul that he and Putin agreed in a phone call after the murder that "our expanding areas of cooperation with Russia, particularly on Syria, will not be hampered by this attack".

The lone gunman shouted "Allahu Akbar" ("God is the Greatest") and "Don't forget Aleppo", vowing that those responsible for events in Syria would be held accountable. Altintas did not go through the metal detector security check when he entered the exhibition and was warned by a security officer, according to the Cankaya municipality where the exhibition centre is located. But after showing his police ID, he was allowed to proceed, it said.

The Hurriyet daily said Altintas, who had worked for Ankara's anti-riot police for the last two-and-a-half years, had stayed at a nearby hotel to prepare for the attack, shaving and putting on a smart suit.

He was killed by police after a 15-minute standoff.

Ankara mayor Melih Gokcek, known for his outspoken comments, speculated on Twitter that the gunman may be linked to the group of exiled Turkish cleric Fethullah Gulen, blamed for the July coup aimed at toppling Erdogan. His suggestion was also repeated in the pro-government press. "We have started to work out the links," said Erdogan, without specifying further.

Gulen, who denies having any involvement in the failed coup, issued a statement condemning "in the strongest terms this heinous act of terror".

Hours after the assassination, an individual fired outside the main gate of the US embassy in Ankara.

The mission said in a statement that no-one was hurt and the individual was detained but the embassy and consulates in Istanbul and Adana were closed for normal operations.

US President-elect Donald Trump had on Monday condemned the envoy's assassination, calling the gunman a "radical terrorist".

Karlov's body, draped in a Russian flag, was given a ceremonial farewell with full state honours on the tarmac of Ankara's Esenboga Airport before being put on a Russian plane for Moscow.

Watched by his widow clutching a candle, an Orthodox Russian priest read the last rites and swung incense over the coffin.

Foreign Minister Mevlut Cavusoglu announced in Moscow that the street where the embassy is located would be named after the 62-year-old envoy, a career diplomat who had notably served as ambassador to North Korea.

The killing came after days of protests in Turkey over Russia's role in Syria, although Moscow and Ankara are now working closely together to evacuate citizens from the battered city of Aleppo.

Turkey and Russia stand on opposite sides of the conflict, with Ankara backing rebels trying to topple Moscow's ally President Bashar al-Assad.

But the rhetoric has warmed considerably since a reconciliation deal was signed earlier this year and the tripartite meeting Tuesday was just the latest in a series of contacts.

Russia, Iran and Turkey agreed on Tuesday to guarantee Syria peace talks and backed expanding a ceasefire in the war-torn country, Russian Foreign Minister Sergei Lavrov said after the meeting.