ISTANBUL (AP) -- Turkish police captured the gunman who carried out the deadly New Year's nightclub attack in Istanbul, with officials saying Tuesday that he's an Uzbekistan national who trained in Afghanistan and confessed to the massacre.
The man was being questioned by police, Prime Minister Binali Yildirim told reporters in Ankara. Yildirim expressed hope that the interrogation would unveil the "forces" behind the attack, which killed 39 people and has already been claimed by the Islamic State group.
Hundreds of people were gathered at the swanky Reina nightclub to celebrate the end of a tumultuous 2016 only to become the first victims of 2017. The gunman shot a police officer and a civilian outside the club, before storming the club.
Most of the dead in the attack were foreign nationals, mainly from the Middle East.
"The vile terrorist who attacked the place of entertainment on New Year's Eve and led to the loss of so many lives has been captured," Yildirim said.
He added: "What is important is for the suspect to be captured and for the forces behind it to be revealed."
The premier wouldn't provide further details on the arrest or the investigation, saying authorities would provide specifics "in time."
Moments later in separate remarks, Istanbul governor Vasip Sahin said that the suspect is an Uzbekistan national who trained in Afghanistan. He is believed to have entered Turkey in January 2016. Sahin identified him as Abdulkadir Masharipov, saying he was born in 1983 without giving an exact birthday. Turkish media have reported the suspect's first name as Abdulgadir.
Sahin said that the man, captured late Monday, confessed to carrying out the massacre and that his fingerprints matched those of the attacker. He can be held for up to 30 days under Turkey's state of emergency, which was introduced after a failed coup attempt in July, before he is charged and formally arrested. It could take prosecutors several months to prepare for a trial.
The suspect, according to Sahin, was a well-educated terrorist who speaks four languages and had clearly carried out the attack in the name of IS. He was operating under the alias "Ebu Muhammed Horasani."
The police operation to apprehend him drew on the review of 7,200 hours of security camera footage and about 2,200 tipoffs from the public. Police searched 152 addresses and 50 people were taken into custody.
Authorities seized nearly $200,000, two guns and two drones during the suspect's arrest.
"Together with the terrorist, an Iraqi man was detained as well as three women from various countries — from Egypt and from Africa," Sahin said. "There is a high chance that they may be connected (to IS) because they were staying in the same house."
The governor said it was believed that they arrived three days earlier at Esenyurt, an overall low-income neighborhood of Istanbul that has witnessed a construction boom.
The state-run Anadolu Agency said that the gunman's 4-year-old son was taken into protective custody.
Hurriyet newspaper earlier reported that the suspect's wife and 1-year-old daughter were caught in a police operation in the neighborhood of Zeytinburnu, a working class district of Istanbul, on Jan. 12.
In another report citing police officials, the newspaper said the gunman had picked up his son from the working-class neighborhood of Zeytinburnu after attacking the nightclub.
Sahin said the boy wasn't with the gunman on the night of the police operation, although he had taken the child with him and left his daughter with his wife.
IS has claimed responsibility for the nightclub massacre, saying the attack in the first hours of Jan. 1 was in reprisal for Turkish military operations in northern Syria. The man identified as the suspect had been on the run since the attack.
Days after the attack, Deputy Prime Minister Numan Kurtulmus said an intelligence agency may have been involved, an assertion he reiterated Monday. But Sahin, when asked about it, declined to comment saying: "It is too soon to say anything about such connections."
Anadolu said police have also carried out raids on members of a suspected Uzbek IS cell in five Istanbul neighborhoods, and detained several people.
Photographs from raids, widely published in the Turkish media, showed a bruised, black-haired man in a gray, bloodied shirt being held by his neck. NTV television said the gunman had resisted arrest.
Turkish media also circulated a photograph of the Iraqi suspect lying on the floor facedown, hands bound behind his back with the boot of an unidentified man pressed to the back of his head.
Speaking in Ankara, President Recep Tayyip Erdogan said the operation to apprehend the suspect was successful and thanked his country's security and intelligence agencies for their efforts.
"In this country, no one will slip through the net, everyone will be held to account within the limits of the rule of law," he said.
Turkey, a member of NATO and a partner in the U.S.-led coalition against IS, has endured multiple attacks attributed to the extremist group. IS said the assault on the nightclub was retaliation for Turkey's military operations in northern Syria.
The country has also witnessed an uptick in violence linked to the resumption of conflict between the Turkish state and Kurdish militants.