John Bacon

USA TODAY

The Islamic State claimed responsibility Monday for the shooting rampage at a packed Istanbul nightclub that left 39 dead and scores wounded, including an American who said he played dead to avoid additional gunshots.

Turkish authorities said they detained eight people in connection with the attack that rocked the city in the early hours of New Year's Day, but a manhunt for the gunman continued. A raid Monday night on an apartment in Istanbul didn't result in any arrests, according to the Associated Press.

Earlier, Deputy Prime Minister Numan Kurtulmus said authorities were close to identifying the gunman after obtaining fingerprints and a description of his appearance, the AP reported.

The bloodshed was revenge for Turkish military involvement in Syria, the jihadist group said in a statement released through Aamaq News Agency, which has ties to the militant group.

"The apostate Turkish government should know that the blood of Muslims shed with airplanes and artillery fire will, with God's permission, ignite a fire in their own land," according to the statement as translated by Reuters news service.

The gunman killed a police officer and a civilian outside the Reina club shortly after midnight. He then entered the crowded club amid the New Year's Eve revelry, firing at will with a long-barreled weapon. Reports said more than 500 people were packed into the venue.

A year of deadly attacks in Turkey

Some of the attack was captured on video, which shows the gunman dressed in black and carrying a backpack as he shoots the officer. Social media posts in support of the attack drew outrage from the Turkish government. Prime Minister Binali Yıldırım called for "responsible" social media use, warning on Twitter that praising terrorism could have "criminal consequences."

Kurtulmus said more than 300 social media accounts determined to “sow discord” were under investigation, Turkey's Hurriyet Daily News reported. And Turkish Bar Association head Metin Feyzioğlu said her group would file complaints against all people who praise terror on social media.

The U.S. Embassy in Ankara defended itself from social media attacks after the blast, saying U.S. officials had no knowledge of any specific target when it issued a general warning about travel to Turkey days before the blast.

"Contrary to rumors circulating in social media, the U.S. Government had no information about threats to specific entertainment venues, including the Reina Club," the embassy said in statement.

More than half the victims were from other countries, Turkey’s state-run news agency reported. James Piazza, a Penn State professor and Middle East expert, said Reina could have been targeted by Turks who view Reina as a symbol of Western elitism. The Islamic State's role in the tragedy is unclear, he said.

"Did the Islamic State help plan and execute the attack? Or, rather, did it just serve as an ideological motivator for the attack?" Piazza said.

Among the injured was a businessman from Greenville, Del. William Jacob "Jake" Raak, 35, was visiting friends in Istanbul, where he went to celebrate his 35th birthday. NBC News obtained video of Raak, on a stretcher, being placed in an ambulance at the scene.

"I was shot in the (expletive) leg, man," Raak says. "These crazy people came in shooting everything!"

Later, Raak said he was on the ground when he was shot.

"I just let him shoot me," he said. "You just have to stay as calm as you can... I took a bullet."

His brother, Michael, told the TV station Jake probably avoided more serious injury because the bullet initially hit Jake's cellphone.

Jake Raak spoke briefly at the airport before flying home.

"I was with nine people. Seven of us were shot," he said. "All I can say is it's a massive tragedy."

Turkey has been a prime target for terror attacks for months. More than 40 people, most of them police officers, were killed in twin bombings in Istanbul three weeks ago. A Kurdish militant group claimed responsibility for that attack.

The Islamic State is suspected in an August blast at a wedding near the Syrian border that killed more than 50 people and a June attack at Istanbul's Ataturk Airport that killed more than 40. Turkey has been a key member of the U.S.-led international coalition combating the Islamic State.

President Recep Tayyip Erdogan condemned Sunday's "vicious attack" and offered condolences for the victims and their loved ones.

"Turkey will stand together and not give passage to dirty games of terrorists," he said.

Contributing: Steph Solis