ISTANBUL (AP) — A gunman suspected of killing 39 people during a New Year’s attack on an Istanbul nightclub has been caught in a police operation, Turkish media reports said early Tuesday.

The suspect was captured in a special operations police raid on a house in Istanbul’s Esenyurt district, private NTV television reported. The broadcaster said he had been staying in the house belonging to a friend from Kyrgyzstan.

The Islamic State group 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.

Hurriyet newspaper and other media have identified the gunman as Abdulkadir Masharipov, an Uzbekistan national. The suspect was to undergo medical checks before being taken to police headquarters for questioning, the paper said in its online edition.

Dogan news agency published what it said was the first image of the attacker. It showed a bruised, black-haired man in a grey, bloodied shirt being held by his neck. Private NTV television said the gunman had resisted arrest.

NTV reported that the alleged gunman’s Kyrgyz friend and three other people also were detained. His 4-year-old child, who was with him at the home, was taken into protective custody.

Hurriyet newspaper said the alleged gunman’s wife and 1-year old daughter were caught in a police operation on Jan. 12.

Police established his whereabouts four or five days ago, but delayed the raid so they could monitor his movements and contacts, NTV reported.

The television channel also broadcast footage showing plain-clothed police taking away a man in a white top and sweat pants, forcing his head down. The station said the images showed the gunman’s Kyrgyz friend being taken to a police vehicle.

The state-run Anadolu Agency likewise reported the arrest and identified the gunman, only with a slightly different spelling of his first name, Abdulgadir. It said a Kyrgyz man and three women were detained with him

Anadolu said the suspects were being taken to Istanbul’s main police headquarters for questioning. Police were carrying out raids on other suspected Islamic State group cells, the news agency said without providing details.

Turkish Foreign Minister Mevlut Cavusoglu posted a Twitter message thanking the interior minister, Suleyman Soylu, police and intelligence organizations “who caught the Reina attacker in the name of the people.”

Earlier in the day, Turkish Deputy Prime Minister Numan Kurtulmus said the Reina nightclub attack had been carried out professionally with the help of an intelligence organization, a claim he had made in the first days after the attack. He did not name the organization suspected of being involved.

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, then stormed the premises.

Most of the dead in the attack on the upscale club were foreign nationals, from the Middle East. The gunman had reportedly left Reina in a taxi.

___

Fraser reported from Ankara. AP Writer Dominique Soguel contributed from Basel, Switzerland.