The suspected gunman who killed 39 people in a New Year's Eve attack on an Istanbul nightclub has been arrested, Turkish police said on Tuesday.
The suspect has been named as Abdulkadir Masharipov. According to Istanbul governor Vasip Sahin, he was born in 1983 in Uzbekistan and was trained in Afghanistan.
Masharipov was reportedly captured in the Esenyurt district of Istanbul along with four others overnight, just 19 miles from the Reina nighclub where the attack took place.
Among the dead were Turks, along with visitors from India, Canada, Israel, France and other countries. The attacker reportedly shot his way into the nightclub and opened fire with an automatic rifle. He reloaded his weapon several times and shot the wounded as they lay on the ground.
Sahin said on Tuesday that Masharipov had admitted his guilt and his fingerprints matched those at the scene.
"He knew four languages and was well-educated," Sahin told a news conference.
There were strong indications Masharipov entered Turkey illegally through its eastern borders in January 2016 and it was clear the attack was carried out on behalf of Islamic State, Sahin said.
The jihadist group claimed responsibility a day after the mass shooting, saying it was revenge for Turkish military involvement in Syria.
A Quran was found at the hideout where Masharipov was caught.
In the aftermath of the attack, Pope Francis led world religious leaders in condemning the deadly incident.
Speaking to pilgrims and tourists gathered in St Peter's Square for the New Year's Day Angelus, Pope Francis departed from his prepared text to offer prayers for the victims.
He said, "Deeply saddened, I express my closeness to the Turkish people, I pray for the many victims and the injured and for the whole nation in mourning, and I ask the Lord to support all people of good will who courageously roll up their sleeves to face the plague of terrorism and the bloody stain that envelops the world with a shadow of fear and bewilderment."
The Archbishop of Canterbury Justin Welby retweeted a Church of Engand prayer for the victims: "Restless with grief and fear, the abandoned turn to you: In every hour of trial, Good Lord, deliver us."
Masharipov was captured with an Iraqi man and three women from Africa, one of them from Egypt.
Two pistols, mobile phone SIM cards, and $197,000 in cash were also seized, Sahin said.
Dogan news agency published a photo of the alleged attacker with a black eye, a cut above his eyebrow and bloodstains on his face and t-shirt. It broadcast footage showing plain-clothes police leading a man in a white sweater to a waiting car.
He was being questioned at Istanbul police headquarters, while other people were detained in raids across the city targeting Uzbek Islamic State cells, the state-run Anadolu news agency said.
The gunman appeared to have repeatedly changed addresses before and after the attack. Remaining in Istanbul, he evaded a 16-day nationwide manhunt that included operations in cities from Izmir on the Aegean coast, to Konya in central Anatolia, and Hatay near the southern border with Syria.
"Five addresses were tracked and operations were carried out against them. He was found at one of the five addresses," Sahin said.
It appeared Masharipov and those seized with him had moved to the Esenyurt address three days ago, he said.
Masharipov had first rented an apartment in Basaksehir, another outlying Istanbul district, before switching addresses a day or two before the attack, the Istanbul governor said.
About 50 people have been detained in raids on 152 addresses since the shooting. Investigators analysed 7,200 hours of camera footage in the search and police received more than 2,000 tip-offs, Sahin said.
'War with terror' will continue
"I congratulate our police who caught the perpetrator of the Ortakoy massacre," Deputy Prime Minister Numan Kurtulmus, who is also the government spokesman, said on Twitter.
"Our war with terror and the powers behind it will continue to the end," he said.
NATO member Turkey is part of the US-led coalition against Islamic State and launched an incursion into neighbouring Syria in August to drive the radical Sunni militants, and Kurdish militia fighters, away from its borders.
The jihadist group has been blamed for at least half a dozen attacks on civilian targets in Turkey over the past 18 months. But, other than assassinations, the new year attack was the first it has directly claimed.
Masharipov was caught in an apartment at a housing complex in Esenyurt at around 11 pm (2000 GMT) on Monday.
The shooting in Istanbul's Ortakoy neighbourhood, an upscale district on the Bosphorus shore, followed a year in which Turkey was shaken by a series of attacks by radical Islamist and Kurdish militants and by a failed coup.
President Tayyip Erdogan has said the attack, which targeted a club popular with local celebrities and moneyed foreigners, had been being exploited to try to divide the largely Sunni Muslim nation.
Additional reporting by Reuters