The main suspect in the New Year attack on an Istanbul nightclub has been arrested. Turkish police reportedly detained him and four others in the Esenyurt district of the city.

Media reports say Abdulkadir Masharipov was captured in a police operation which targeted the apartment of a friend. The suspect’s four-year-old son was with him.

Suspect in New Year's nightclub massacre in Istanbul is captured, Turkish media reports https://t.co/LMWcJGMrvy — New York Times World (@nytimesworld) January 16, 2017

Masharipov is thought to be the gunman who opened fire with an automatic rifle in the exclusive Reina club, killing 39 people and injuring around 65 others.

Turks as well as visitors from several Arab nations, India and Canada were among those killed in the attack.

Dozens of people have previously been detained in connection with the shooting for which the Islamist militant group ISIL has claimed responsibility in what it said was revenge for Turkish military involvement in Syria. The arrest followed a two-week, nation-wide manhunt.

Masharipov is an Uzbek national who allegedly trained with ISIL in Afghanistan. Media reports say he rented a flat in 2016 in the central Turkish city of Konya with two children and a woman believed to be his wife. He arrived in Istanbul in December last year. The other people arrested include a man of Kyrgyz origin

and three woman from Egypt, Senegal and Somalia.

“I congratulate our police who caught the perpetrator of the Ortakoy massacre,” Deputy Prime Minister Numan Kurtulmus, who is also the government spokesman, said on Twitter.

He added: “Our war with terror and the powers behind it will continue to the end.”

Masharipov has reportedly admitted guilt already and his fingerprints are said to match those found at the scene.