Turkish police have arrested the main suspect in the New Year's Eve attack on an exclusive nightclub in Istanbul after a huge manhunt.
Abdulkadir Masharipov is believed to have mounted the assault on the Reina club which left 39 people dead.
The Uzbek national is said to have been caught in Istanbul's Esenyurt district.
Citizens of Israel, France, Tunisia, Lebanon, India, Belgium, Jordan and Saudi Arabia were among the victims, and dozens of people were injured.
So-called Islamic State (IS) said it was behind the attack, saying it was revenge for Turkish military involvement in Syria.
The gunman arrived at the club by taxi early that Sunday, before rushing through the entrance with a long-barrelled gun he had taken from the boot of the car.
He fired randomly at people celebrating the new year.
A huge relief: By the BBC's Mark Lowen, Istanbul
It was the culmination of a huge police manhunt: a raid on the Istanbul suburb of Esenyurt that finally caught the alleged Reina attacker, named as Uzbek national Abdulkadir Masharipov.
Photographs show him with a heavily bruised face, wearing a grey T-shirt and being held by his throat.
There had been fears that the gunman had managed to escape Turkey, perhaps to territory held by so-called Islamic State, which said it was behind the attack.
The Turkish authorities will be hugely relieved at his capture. But the far greater challenge for them is to secure this country and step up intelligence to halt the wave of terror attacks that has engulfed Turkey.
Police reportedly found the suspect along with his four year-old son at the home of a Kyrgyz friend in the city. Turkish media say that his friend was also detained, along with three women.
According to the Hurriyet newspaper, he was due to undergo medical checks before being taken in for interrogation at a police headquarters.
Deputy Prime Minister Numan Kurtulmus posted a message on the social media site Twitter congratulating authorities on capturing the suspect, adding: "Our war with terror and the powers behind it will continue to the end."
Who is Abdulkadir Masharipov?
- Originally from the Central Asian republic of Uzbekistan, he reportedly arrived in Konya, central Turkey, with his family at the beginning of 2016
- Said to have assumed the name Ebu Muhammed Horasani
- Described by Turkish media as a member of the Islamic State group
Sources: Turkish media
Turkish media report that the suspect rented a flat in the central Turkish city of Konya with a woman believed to be his wife and two children. He arrived in Istanbul on 15 December, according to Hurriyet's sources.
The reports add that police also carried out raids on other suspected IS militants.
Turkey has been battling IS inside northern Syria while seeking to push back ethnic Kurds in the region too.
Reina was one of Istanbul's best-known clubs, with a view across the Bosphorus towards Asia.
It attracted singers, actors and sports stars as well as foreign tourists.
Reported IS attacks in Turkey
20 August 2016: Bomb attack on wedding party in Gaziantep kills at least 30 people, in an attack claimed by IS
28 June 2016: A gun and bomb attack on Ataturk airport in Istanbul kills 41 people, blamed on IS militants
19 March 2016: Suicide bomb kills four people in shopping street in Istanbul. IS blamed
12 January 2016: 12 Germans killed by IS bomber in tourist area of Istanbul
10 October 2015: More than 100 killed at peace rally outside railway station in Ankara; blamed on IS
20 July 2015: 34 people killed in bombing in Suruc, near Syrian border; IS blamed