Turkey's state run news agency says the gunman suspected of killing 39 people in a nightclub attack on New Year's Day has been formally arrested.

Abdulkadir Masharipov, an Uzbek citizen born in 1983, was caught at a hide-out in Istanbul on Jan. 16 after evading police for more than two weeks.

The prosecutor demanded his arrest on charges of attempting to overthrow the constitutional order, being a member of an armed terror organization and murder, the Anadolu news agency reported Saturday.

Authorities said the suspect was trained in Afghanistan and staged the attack for the Islamic State group.

IS has claimed responsibility for the attack.