1The man believed to have killed 39 people on New Year’s night at an Istanbul nightclub has confessed after Turkish police captured him in a massive operation, a local official said on Tuesday.

“The terrorist confessed his crime,” Istanbul governor Vasip Sahin told reporters, identifying the detained man as Abdulgadir Masharipov, born in Uzbekistan.

The alleged assailant was found along with his four-year-old son in an apartment in the Esenyurt district of Istanbul after a massive police operation, state-run TRT television reported.

The attacker had been on the run for over two weeks, after slipping into the night following the attack on the glamorous Reina nightclub on the Bosphorus.

Reports had previously suggested he never left the Turkish metropolis, despite a tightening of borders in a bid to stop him escaping, triggering fears that a dangerous killer was on the loose in the city.

The ISIS group took responsibility for the bloodbath, the first time it has ever openly claimed a major attack in Turkey.

It had previously been blamed for several strikes including triple suicide bombings at Istanbul airport in June.

The suspect was caught in an operation jointly carried out by the Turkish police and the spy agency MIT, Turkish TV said.

Turkish media published a picture of the detained man with blood on his face and T-shirt, his neck gripped by a policeman.

Television images showed him being roughly led away, his head bent low.

Of the 39 killed in the attack on the glamorous nightclub, 27 were foreigners including citizens from Lebanon, Saudi Arabia, Israel, Iraq and Morocco who had been hoping to celebrate a special New Year.

The attack, just 75 minutes into 2017, rocked Turkey which had already been shaken by a string of attacks in 2016 blamed on jihadists and Kurdish militants that left hundreds dead.

Turkey had been accused by its Western allies of not doing enough to halt the rise of ISIS but the charges are denied by the Turkish authorities, who note the group has been listed as a terror organisation in the country since 2013.