Turkey’s prime minister said Tuesday that the man suspected of carrying out the deadly New Year’s Eve attack on an Istanbul nightclub has been detained.

Binali Yildirim told reporters in Ankara that the man was being questioned by police, and expressed hope that the interrogation would unveil the “forces” behind the attack that left 39 people dead.

Istanbul’s governor has said the attack was executed on behalf of the Islamic State of Iraq and Syria (ISIS), which claimed responsibility just a couple days after the massacre.

Get Breaking News Delivered to Your Inbox

Yildirim wouldn’t provide further details on the arrest or the investigation, saying authorities would provide them “in time.”

“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,” the prime minister said, adding that it was still vital for the “forces behind” the attack to be revealed.

“It is clear that this was carried out in the name of Daesh,” Istanbul Governor Vasip Sahin told reporters, using an Arabic acronym for the militant group.

Sahin also confirmed the identity of the suspected gunman as Abdulgadir Masharipov, an Uzbek national who had trained in Afghanistan and is believed to have entered Turkey in January 2016. Masharipov is 33 or 34 years old.

Sahin said the suspect, captured late Monday, had confessed to carrying out the massacre, adding that his fingerprints matched those of the attacker.

An unidentified man is subdued and detained during a police operation to capture the Reina nightclub attacker, in Istanbul, Turkey, Jan. 16, 2017. AP

The state-run Anadolu Agency said a man from Kyrgyzstan and three women -- from Somalia, Senegal and Egypt -- were also detained in the raid, while the gunman’s 4-year-old son was taken into protective custody.

Turkish media reports as Abdulgadir Masharipov and was caught in a police operation at a luxury residential complex in Istanbul.

ISIS 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.

Anadolu said police have also carried out raids on members of a suspected Uzbek ISIS cell in five Istanbul neighborhoods, and detained several people.

Authorities had set up a 1,000-person force to capture the gunman, Anadolu said.

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.

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 premises.

Most of the dead in the attack on the upscale club were foreign nationals, mainly from the Middle East.