Turkish police have detained six people over the killing of Russia's ambassador Andrei Karlov, security sources said, widening an investigation to relatives of the off-duty policeman who shouted "Don't forget Aleppo!" as he gunned the envoy down.

Both countries cast Monday's attack at an art gallery in the capital Ankara as an attempt to undermine a recent thawing of ties that have been strained by civil war in Syria, where they back opposing sides.

The war, which has killed more than 300,000 people and created a power vacuum exploited by Islamic State, reached a potential turning point last week when Syrian forces ended rebel resistance in the northern city of Aleppo.

Russia, an ally of President Bashar al-Assad, supported that advance with air strikes.

Karlov's remains were sent back to Moscow from Turkey after a ceremony at the airport in Ankara.

The white, red and blue Russian flag was draped on the casket as a Russian Orthodox priest recited prayers.

Turkey identified the killer as 22-year-old Mevlut Mert Altintas, who had worked for the Ankara riot police for 2-1/2 years. Altintas, who also shouted slogans associated with Islamist militancy after shooting ambassador Karlov, was killed minutes later by members of Turkey's special forces.

His mother, father, sister and two other relatives were held in the western province of Aydin, while his flatmate in Ankara was also detained, security sources said.

One senior Turkish security official said investigators were focusing on whether Altintas had links to the U.S.-based Muslim cleric Fethullah Gulen, whom Ankara blames for a failed July coup. Gulen has denied responsibility for the coup and Monday's attack and has condemned both events.

The slogans that Altintas shouted, which were captured on video and circulated widely on social media, suggested he was aligned to a radical Islamist ideology, rather than that of Gulen, who preaches a message of interfaith dialogue.

"Don't forget Aleppo, don't forget Syria. You will not be able to feel safe for as long as our districts are not safe. Only death can take me from here," he shouted in Turkish.

Turkish President Tayyip Erdogan said on Monday he and Russia's Vladimir Putin had agreed in a telephone call to strengthen cooperation in fighting terrorism.

Putin said it was aimed at derailing Russia's attempts to find, with Iran and Turkey, a solution for the Syria crisis. The foreign ministers of three countries, meeting in Moscow on Tuesday, said they were ready to broker a Syrian peace deal.

'ALLEGIANCE TO JIHAD'

Turkey faces multiple security threats, including from Islamic State. Earlier this month a spokesman for the hardline Sunni Muslim group urged global sympathisers to carry out new attacks, singling out Turkish diplomatic, military and financial interests as preferred targets.

Altintas also shouted "We are the ones who swore allegiance to Mohammed for the jihad!", which the mass circulation Hurriyet newspaper said was a slogan commonly used in propaganda videos of the group formerly allied to al Qaeda in Syria.

Media present at the event Karlov was attending, an exhibition of photographs from Russia, captured the killing in graphic detail.

Altintas, dressed in a suit, necktie and white shirt, is caught in one photograph standing behind Karlov. In a video, Karlov is shown crumpling as he appears to be shot from behind.

As special forces stormed the building, Altintas initially waited by the ambassador's body and would not allow him to be treated, Hurriyet reported.

An initial police report said that 11 shots were fired on the ambassador and nine were on target, the senior security official said. In a video message to the nation on Monday evening, Erdogan said Altintas had graduated from a police academy before joining the riot police.

Russian investigators arrived in Ankara on Tuesday, officials from the Kremlin and the Turkish presidency said.

Foreign Minister Mevlut Cavusoglu said the street where the Russian embassy is located would be named after the ambassador.

The gallery where the shooting occurred is opposite the U.S. embassy. A gun was fired in front of the embassy overnight and the United States said its three missions in Turkey would be closed on Tuesday.