The man suspected of carrying out the New Year's Eve attack on a nightclub in Istanbul was trained in Afghanistan, the city's governor says.
Vasip Sahin said the man, named earlier as Uzbek national Abdulkadir Masharipov, was believed to have entered Turkey in January 2016.
Mr Sahin said the suspect had confessed to the attack and that his fingerprints matched those found at the scene.
Thirty-nine people died in the attack on the Reina club with dozens wounded.
Citizens of Israel, France, Tunisia, Lebanon, India, Belgium, Jordan and Saudi Arabia were among the victims.
So-called Islamic State (IS) said it was behind the attack, saying it was revenge for Turkish military involvement in Syria.
Police detained the man on Monday evening in a raid on an address in the Istanbul suburb of Esenyurt. Initial reports said a Kyrgyz man was also held but Mr Sahin said on Tuesday that a man of Iraqi origin and three women of Egyptian and African origin were detained.
A picture of Abdulkadir Masharipov taken shortly after his arrest showed him being held by the neck by an officer with his face bruised and bloodied.
Who is Abdulkadir Masharipov?
- Born in 1983 in the Central Asian republic of Uzbekistan
- Allegedly trained as a militant in Afghanistan and entered Turkey illegally across its eastern borders in January 2016
- Said to have assumed the name Ebu Muhammed Horasani
- Believed to have carried out the Istanbul attack on behalf of the Islamic State group
Source: Istanbul Governor Vasip Sahin
Turkish police can question the suspect for up to 30 days without charging him under state of emergency laws that were introduced after last July's failed coup.
Mr Sahin said that contrary to earlier reports, the suspect's four year-old son was not with him when he was detained.
The governor said it was "clear that [Masharipov] staged the attack on behalf of Daesh," using the Arabic acronym for the IS group.
"He was trained in Afghanistan and can speak four languages. He's a well-trained terrorist," Mr Sahin added.
Police also seized pistols, ammunition, two drones and nearly $200,000 (£164,000) in the raid, he said.
President Recep Tayyip Erdogan congratulated security forces after the operation.
"From now on in this country nobody will get away with what they have done. Everyone will be brought to account within the rule of law," he said in Ankara.
The attack on the nightclub began when the gunman arrived by taxi and rushed through the entrance with a long-barrelled gun taken from the boot of the car.
He fired randomly at people celebrating the New Year.
A huge manhunt was launched amid fears that the gunman had escaped Turkey, perhaps to territory held by IS.