Gunman kills 39 in Istanbul nightclub, manhunt under way

* Revellers cower under tables, some jump into Bosphorus

* Nightclub favoured by foreigners and "high society"

* Assailant cries "Allahu Akbar", witness says (Adds witness testimony, Putin statement)

By Humeyra Pamuk and Nick Tattersall

ISTANBUL, Jan 1 (Reuters) - A gunman opened fire on New Year revellers 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 to save themselves after the attacker began shooting at random in the Reina nightclub just over an hour into the new year. Witnesses described diving under tables as the assailant walked around spraying bullets from an automatic rifle.

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".

"At first we thought some men were fighting with each other," said a Lebanese woman who gave her name as Hadeel and who was in the club with her husband and a friend. "Then we heard the sound of the gunfire and ducked under the tables.

"We heard the guy screaming Allahu Akbar (God is Greatest), all three of us heard that ... We heard his footsteps crushing the broken glass," she told Reuters. "We got out through the kitchen, there was blood everywhere and bodies."

Officials spoke of a single attacker, a "lone wolf" in the parlance of Islamic State, but some reports citing witnesses including on social media suggested there may have been several.

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.

Nationals of Saudi Arabia, Morocco, Lebanon, Libya, Israel, a Turkish-Belgian dual citizen and a Franco-Tunisian woman were among those killed, officials said. Saudi newspaper al-Riyadh said five of the dead were from Saudi Arabia.

France said three of its citizens were wounded.

A massive security operation unfolded to track down the fugitive assailant or assailants and any conspirators.

Turkish 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.