(CNN) A man from Uzbekistan arrested in Turkey has confessed to carrying out the deadly New Year's gun attack at Istanbul's Reina nightclub, the city's governor has said, dubbing the shooting an ISIS-influenced terrorist attack.
Abdulgadir Masharipov allegedly opened fire in the early hours of New Year's Day in an attack that left 39 people dead and dozens injured, in a gruesome beginning to the new year following multiple acts of terror in 2016.
"The terrorist actually said that he did it," Istanbul Governor Vasip Sahin told journalists Tuesday.
Masharipov was born in 1983 and was educated in Afghanistan, Sahin said. He came to Turkey in January 2016 and went by the code name Abu Mohammed Khorasani Abdulkavi.
The attack was "based on ISIS," Sahin said.
He added that 168 foreigners were handed over to related authorities on suspicion of being terrorists and that one Iraqi man and three women from different places, including Egypt, were detained alongside Masharipov.
"During this operation we have gone through 152 addresses, and in these operations, we detained 50 people."
ISIS claimed responsibility for the attack -- the militant Islamist group typically refrains from claiming responsibility for attacks in Turkey to create "an environment of suspicion in Turkish politics," analyst Soner Cagaptay wrote for CNN in 2016.
The claim could be seen as a "a declaration of war on Turkey," CNN intelligence and security analyst Bob Baer said.
The nightclub was a glittering waterside venue frequented by Turkey's wealthy secular millennials and international celebrities. Ortakoy, where Reina is located, is a vibrant seaside neighborhood that caters to a wide range of people, from the uber-rich who party at clubs like Reina to students who buy stuffed baked potatoes from vendors along the Bosphorus shore.
Around 1:15 am on New Year's Day, the gunman shot and killed a police officer who was guarding the front gate, then rushed inside, spraying gunfire. Revelers jumped into the freezing waters of the Bosphorus to escape the chaos.
The nightclub's owner, Memet Korcarslan, told CNN he felt "an immense wave of relief rush through me" upon hearing news of arrests.
"I think a huge weight has been lifted off the shoulders of all the victims and their families just knowing that this man is no longer walking free," he said.
"The Turkish police and Turkish intelligence have carried out a very successful operation by catching him alive. I hope they will find anyone else who was involved with this heinous attack."