ISTANBUL -- Turkish media reports say police have caught the alleged gunman who killed 39 people during an attack on a nightclub in Istanbul during New Year’s celebrations.

The private Dogan news agency and other media say the suspect was caught in Istanbul’s district of Esenyurt in a police operation late on Monday.

The Islamic State of Iraq and Syria (ISIS) has claimed has claimed responsibility, saying the attack was in reprisal for Turkish military operations in northern Syria.

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 a police headquarters for questioning, the paper said in its online edition.

Get Breaking News Delivered to Your Inbox

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.

Reina club alleged attacker after being caught by Turkish police in Istanbul, late Monday, Jan. 16, 2017. AP

NTV reported that the 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.

The television channel said police established the gunman’s whereabouts four or five days ago, but delayed the raid so they could monitor his movements and contacts.

The state-run Anadolu Agency also 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

An unidentified man is subdued, detained during a police operation to capture Reina club attacker, in Istanbul, Turkey, late Monday, Jan. 16, 2017. AP

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

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.

Previously it was reported that the suspect arrived at the club by taxi, striking at 1:15 in the morning on New Year’s Day. He killed a police officer at the entrance, and barely missed the club’s co-owner, who jumped over a railing, CBS News’ Jonathan Vigliotti reported.

“When I opened my eyes, he was still there,” said Ali Unal, the co-owner. “I was thinking to jump on him, but he seemed so professional, he had flexibility.”

Inside, the gunman moved methodically, using several ammunition clips, indications he may be an experienced shooter.

The gunman left 39 dead and nearly 70 injured in his wake, many of them tourists.

Police say he left the club in another taxi, heading to an apartment near the airport only to walk casually away. Investigators searched the apartment but at the time turned up nothing.