A gunman opened fire on New Year revelers at a packed nightclub on the shores of Istanbul's Bosphorus waterway on Sunday killing at least 39 people, including many foreigners, then fled the scene.
Some people jumped into the Bosphorus waters to save themselves after the attacker opened fire at random in the Reina nightclub just over an hour into the new year. Officials spoke of a single attacker but some reports, including on social media, suggested there may have been more.
The attack shook NATO member Turkey as it tries to recover from a failed July coup and a series of deadly bombings in cities including Istanbul and the capital Ankara, some blamed on Islamic State and others claimed by Kurdish militants.
Security services had been on alert across Europe for new year celebrations following an attack on a Christmas market in Berlin that killed 12 people. Only days ago, an online message from a pro-Islamic State group called for attacks by "lone wolves" on "celebrations, gatherings and clubs".
The Hurriyet newspaper cited witnesses as saying the attackers shouted in Arabic as they opened fire at Reina.
"We were having fun. All of a sudden people started to run. My husband said don't be afraid, and he jumped on me. People ran over me. My husband was hit in three places," one club-goer, Sinem Uyanik, told the newspaper.
"I managed to push through and get out, it was terrible," she said, describing seeing people soaked in blood.
The incident bore echoes of an attack by militant Islamists on Paris's Bataclan music hall in November 2015 that, along with assaults on bars and restaurants, killed 130 people.
Interior Minister Suleyman Soylu said 15 or 16 of those killed at Reina were foreigners but only 21 bodies had so far been identified. He told reporters 69 people were in hospital, four of them in critical condition.
"A manhunt for the terrorist is underway," he said.
Nationals of Saudi Arabia, Morocco, Lebanon, Libya, Israel and Belgium were among those killed, officials said. France said three of its citizens were wounded.
Turkey is part of the U.S.-led coalition against Islamic State and launched an incursion into Syria in August to drive the radical Sunni militants from its borders. It also helped broker a fragile ceasefire in Syria with Russia.
"As a nation, we will fight to the end against not just the armed attacks of terror groups, but also against their economic, political and social attacks," President Tayyip Erdogan said in a written statement.
"They are trying to create chaos, demoralize our people, and destabilize our country ... We will retain our cool-headedness as a nation, standing more closely together, and we will never give ground to such dirty games," he said.
There has been no claim of responsibility, but Erdogan linked the attacks to developments in the region where Turkey faces conflict across its frontier in Syria and Iraq. Some three million Syrian refugees currently live on Turkish soil.
The Reina club is one of Istanbul's best known nightspots, popular with locals and foreigners. Some 600 people were thought to have been inside when the gunman shot dead a policeman and civilian at the door, forced his way in and then opened fire.
Istanbul Governor Vasip Sahin said the attacker used a "long-range weapon" to "brutally and savagely" fire on people, apparently referring to some form of assault rifle.
U.S. President Barack Obama, on vacation in Hawaii, expressed condolences and directed his team to offer help to the Turkish authorities, the White House said.
Dozens of ambulances and police vehicles were dispatched to the club in Ortakoy, a neighborhood on the city's European side nestled under one of three bridges crossing the Bosphorus and home to nightclubs, restaurants and art galleries.
"I didn't see who was shooting but heard the gun shots and people fled. Police moved in quickly," Sefa Boydas, a Turkish soccer player, wrote on Twitter.
"My girlfriend was wearing high heels. I lifted her and carried her out on my back," he said.
Hurriyet quoted Reina's owner, Mehmet Kocarslan, as saying security measures had been taken over the past 10 days after U.S. intelligence reports suggested a possible attack.
Turkey faces multiple security threats including spillover from the war in neighboring Syria. As well as its cross-border campaign against Islamic State, it is fighting Kurdish militants in its own southeast.
The New Year's Day attack came five months after a failed military coup, in which more than 240 people were killed, many of them in Istanbul, as rogue soldiers commandeered tanks and fighter jets in a bid to seize power.
More than 100,000 people, including soldiers and police officers, have been sacked or suspended in a subsequent crackdown ordered by Erdogan, raising concern both about civic rights and the effectiveness of Turkey's security apparatus.
On Dec. 28, the Nashir Media Foundation, which backs Islamic State, urged sympathizers to carry out attacks in Europe during the holiday period and to "replace their fireworks with explosive belts and devices, and turn their singing and clapping into weeping and wailing".
A month ago, a spokesman for Islamic State called on supporters to carry out a wave of attacks and urged them to target "the secular, apostate Turkish government".
Turkey has seen repeated attacks in recent weeks. On Dec. 10, two bombs claimed by Kurdish militants exploded outside a soccer stadium in Istanbul, killing 44 people, most of them police officers, and wounding more than 150.
A car bomb killed at least 13 soldiers and wounded 56 when it ripped through a bus carrying off-duty military personnel in the central city of Kayseri a week later, an attack Erdogan also blamed on Kurdish militants.
The Russian ambassador to Turkey was shot dead as he gave a speech in Ankara on Dec. 19 by an off-duty police officer who shouted "Don't forget Aleppo" and "Allahu Akbar".
In June, around 45 people were killed and hundreds wounded as three suspected Islamic State militants carried out a gun and bomb attack on Istanbul's main Ataturk airport.