Islamic State leader Abu Bakr al-Baghdadi ordered the New Year’s Eve massacre at an upscale nightclub in Istanbul that claimed 39 lives and left scores wounded, it was reported Monday.

The massacre was carried out by a “heroic soldier of the caliphate who attacked the most famous nightclub where Christians were celebrating their pagan feast,” the ISIS-linked Aamaq News Agency said.

The gunman used an automatic rifle in “revenge for God’s religion and in response to the orders” from al-Baghdadi, the news outlet reported.

The terror group described Turkey as “the servant of the cross.”

Anti-terrorism investigators have detained eight people for questioning, but not the shooter, whose identity remains a mystery.

Turkish media, citing authorities, reported that the suspect was likely from either Uzbekistan or Kyrgyzstan.

The gunman fatally shot a police officer and another man outside club Reina after revelers had just rung in the New Year.

He then barged inside the packed club and started indiscriminately shooting at an estimated 600 people with an automatic rifle, killing mostly foreigners from the Middle East. The posh, popular club near the Bosphorus attracts tourists and local celebrities.

Police were investigating whether the nightclub attack was engineered by the same IS cell responsible for the suicide bomb and gun attack at Istanbul’s Ataturk Airport in June, according to Hurriyet and Karar newspapers.

Turkish officials were confident that they would soon find the lone gunman.

“There is strong coordination and we will find him, no delay,” Turkish Prime Minister Binali Yildirim told reporters gathered outside an Istanbul hospital, where he had been visiting people injured in the attack, CNN said.

Turkey’s state-run Anadolu Agency, citing Justice Ministry officials, said 38 of the 39 dead have been identified, – 11 were Turkish nationals and one held dual Turkish-Belgian citizenship.

According to the report, the other victims were from Saudi Arabia, Lebanon, Iraq, Tunisia, India, Morocco, Jordan, Kuwait, Canada, Israel, Syria and Russia.

Dozens of the wounded were still hospitalized as of Monday, including one American. Several were in critical condition.

The mass shooting followed more than 30 violent acts over the past year in Turkey, which is a NATO-ally a member of the U.S.-led coalition fighting against IS in Syria and Iraq.

Turkey’s attacks on Islamic terror holdouts in Syria continued on Monday, with more than 100 IS targets hit by Turkey and Russia in separate operations, Anadolu reported.

Last week, Turkey and Russia brokered a cease-fire for Syria that excludes the IS and other groups considered to be terrorist organizations.

With AP