President Recep Tayyip Erdogan has condemned the nightclub attack that left 39 people dead, saying Turkey will continue to fight against what he called "terrorism" and its backers "until the end".

Erdogan issued a written message after the attack at Istanbul's Reina club early on Sunday morning, as police searched for the gunman.

"They are working to destroy our country's morale and create chaos by deliberately targeting our nation's peace and targeting civilians with these heinous attacks," Erdogan said in the statement.

Offering his condolences for those who lost their lives, including "foreign guests," Erdogan said, "Turkey continues its combat against terror and is absolutely determined to do whatever is necessary in the region to ensure its citizens' safety and peace".

Of the 21 dead identified so far, 15 were foreigners. Nationals of Saudi Arabia, Morocco, Lebanon and Libya were among those killed, Turkish family minister, Fatma Betul Sayan Kaya was quoted by the state-run Anadolu news agency as saying.

Another 69 people were injured in the attack.

READ MORE: Reina nightclub - Party hotspot of Istanbul's elite

Heavily armed police blocked the street in front of the nightclub in the Ortakoy neighbourhood, as crime scene investigators were inside searching through piles of mangled chairs, tables and pieces of clothing left behind by partygoers during the attack.

Turkish police boats were patrolling the Asian side of the Bosporus, on the other side of the club.

Police said the suspected gunman was in his mid-20s and spoke in broken Turkish.

Governor Vasip Sahin said the attacker, armed with a long-barreled weapon, killed a policeman and a civilian outside the club before entering and firing on people partying inside.

"A terrorist with a long-range weapon ... brutally and savagely carried out this incident by firing bullets on innocent people who were there solely to celebrate the New Year and have fun," he said at the scene.

Riot police guard the site of the attack at one of Istanbul's most famous nightclubs [EPA]

The Reina lies on the shore of the Bosphorus Strait and is one of Istanbul's best-known nightclubs, popular with locals and tourists alike.

At least 500 people were thought to have been inside when the attack happened.

There has been no claim of responsibility so far for the attack, but experts say suspicion points towards the Islamic State of Iraq and the Levant (ISIL) group, which has repeatedly attacked civilians in Turkey in recent months.

Al Jazeera's Sinem Koseoglu, reporting from Istanbul, said security services believe the timing and target suggest ISIL involvement. Eight ISIL members had been detained, suspected of preparing a suicide attack on New Year's Eve, she said.

The Reina nightclub is not only frequented by partygoers, but also used as a venue by businessmen and diplomats to conduct meetings, she added.

Koseoglu said those in the club reported seeing up to three attackers, carrying Kalashnikovs.

A witness quoted by the Hurriyet newspaper said she had seen two attackers.

"Two people were shooting with weapons," she said. "Suddenly, people started to run. My husband told me not to be afraid. He jumped on top of me. People ran over me. My man was shot in three places."

TALK TO AL JAZEERA: Erdogan - Will do everything for stability of Turkey

Turkey, part of the US-led coalition against ISIL, faces multiple security threats including fallout from the war in neighbouring Syria.

It has seen repeated attacks and bombings blamed on ISIL, also known as ISIS, as well as the Kurdish fighters of the PKK in recent months.

The PKK and its affiliates are known to target mostly members of Turkey's security forces rather than civilians.

The attack comes less than two weeks after the Russian ambassador to Turkey, Andrey Karlov, was assassinated while giving a speech at an art gallery in the capital Ankara.

On December 10, twin bombings in Istanbul killed at least 45 people, most of whom were police officers.

Relatives of victims gathered in front of the forensic medicine institute after the attack [EPA]


Source: Al Jazeera and news agencies