ISTANBUL -- Prime Minister Justin Trudeau confirmed late Sunday that a Canadian was among those who died in an attack on a Turkish nightclub that killed at least 39 people.

"We mourn with the people of Turkey today and with all countries who lost citizens in this vicious attack," Trudeau said in a statement.

"We also grieve the senseless loss of a Canadian citizen and remain steadfast in our determination to work with allies and partners to fight terrorism and hold perpetrators to account."

The attacker, armed with a long-barrelled weapon, killed a policeman and a civilian outside the Reina club around 1:15 a.m. Sunday before entering and firing at people partying inside, Istanbul Gov. Vasip Sahin said.

"Unfortunately, (he) rained bullets in a very cruel and merciless way on innocent people who were there to celebrate New Year's and have fun," Sahin told reporters.

Nearly two-thirds of the people killed were foreigners, many from the Middle East, Turkey's state-run Anadolu Agency said. It said the bodies of 25 foreign nationals killed in the attack would be delivered to their families Monday.

Countries from India to Belgium reported their citizens among the casualties. Close to 70 people were wounded.

An estimated 600 people were celebrating inside the club, which is often frequented by famous locals, including singers, actors and sports stars. Several shocked revelers were seen fleeing the scene after the shooting and the music fell silent.

There was no immediate claim of responsibility for what authorities immediately called a terrorist attack. Turkish officials did not comment on the possible identity or motives of the gunman.

The mass shooting followed more than 30 violent acts over the past year in Turkey, which is a member of the NATO alliance and a partner in the U.S.-led coalition fighting against the Islamic State group in Syria and Iraq. The country endured multiple bombings in 2016, including three in Istanbul alone that authorities blamed on IS, a failed coup attempt in July and renewed conflict with Kurdish rebels in the southeast.

President Recep Tayyip Erdogan vehemently condemned "the terror attack in Istanbul's Ortakoy neighbourhood in the first hours of 2017" and offered condolences for those who lost their lives, including the "foreign guests."

Among the dead were an 18-year-old Israeli woman, three Indians, three Lebanese, a woman with dual French-Tunisian citizenship and her Tunisian husband, three Jordanians, a Belgian national and a Kuwaiti citizen, according to those countries' foreign ministries and a diplomat.

A U.S. State Department official, who spoke only on condition of anonymity, said one American man was among those wounded. Turkey's minister for family and social policies, Fatma Betul Sayan Kaya, said citizens of Saudi Arabia, Morocco, Lebanon and Libya were among those injured.

Interior Minister Suleyman Soylu said the gunman, who had not been identified, remained at large. "Our security forces have started the necessary operations. God willing, he will be caught in a short period of time," Soylu said.

Private NTV news channel said the assailant was wearing a Santa Claus outfit when he entered the upscale nightclub on the shore of the Bosporus straight, on the European side of the city -- a claim Prime Minister Binali Yildirim denied.

Security camera footage obtained by The Associated Press from Haberturk newspaper shows what appears to be a man dressed in black and carrying a backpack as he shoots down a police officer outside the nightclub. Footage taken by a different camera inside Reina shows a figure wearing different clothes and what could be a Santa Claus hat.

Yildirim said the attacker left a gun at the club and escaped by "taking advantage of the chaos" that ensued. Some customers reportedly jumped into the waters of the Bosporus to escape the attack.

Mehmet Dag, 22, said he was passing by the club when he saw a man shoot at a police officer and a bystander. He said the attacker then targeted security guards, gunning them down and entering the club.

"Once he went in, we don't know what happened. There were gun sounds, and after two minutes the sound of an explosion," Dag said.

Turkish media said the local victims included a 22-year-old police officer and a 47-year-old travel agent, both of whom were shot outside the club.

One was given a funeral Sunday in Istanbul, where his two sons joined the mourners gathered around the flag-draped casket, the private Dogan news agency reported.

Ayhan Arik, a tourism company employee who had taken foreign guests to the nightclub, was shot in the head, the news agency said.

On Sunday, heavily armed police blocked the snowy street in front of the nightclub. The entrance was covered with blue plastic sheeting below a Turkish flag. Police also patrolled the Asian side of the Bosporus on the other side of the club.

Crime scene investigators were seen inside the nightclub searching through mingled piles of chairs, tables and pieces of clothing left behind during the panic among the guests.

There were emotional scenes in front of a city morgue where the dead were taken for identification. Some relatives cried out and fell to the ground as they apparently learned the fate of their loved ones.

The U.S. Consulate General in Istanbul on Sunday warned American citizens to keep their movements in the city "to an absolute minimum." A statement reminded U.S. citizens that extremists "are continuing aggressive efforts to conduct attacks in areas where U.S. citizens and expatriates reside or frequent."

The United States denied reports in Turkish new outlets and on social media that its security agencies knew in advance that the nightclub was at risk of a terror attack. The U.S. Embassy in Ankara said in a statement that "contrary to rumours circulating in social media, the U.S. Government had no information about threats to specific entertainment venues, including the Reina Club."

Turkey faces a wide spectrum of security threats.

The Islamic State group claims to have cells in the country. Analysts think it was behind suicide bombings last January and March that targeted tourists on Istanbul's iconic Istiklal Street as well as a high-casualty suicide bomb and gun attack at Ataturk Airport in June.

In December, IS released a video purportedly showing the killing of two Turkish soldiers and urged its supporters to "conquer" Istanbul. Turkey's jets regularly bomb the group in the northern Syrian town of Al-Bab. Turkish authorities have not confirmed the authenticity of the video.

Turkey's violent 2016 also reflects the intensification of an armed conflict between the government and Kurdish rebels. Turkey-based Kurdish groups have claimed multiple suicide attacks. The government has said Kurdish affiliates in Syria and Iraq share responsibility.

Complicating matters, Turkey endured a coup attempt July 15, which the government blamed on a U.S-based Islamist cleric. A state of emergency has been in force since then, and authorities have purged key institutions, including the army and police.

The violence has left the nation on edge and kept tourists at bay. In Istanbul, a bustling city bridging Europe and Asia, the toll on the economy is evidenced in the closure of iconic restaurants and lowered hotel prices.

The nightclub attack drew quick condemnation from the West and Russia.

Russian President Vladimir Putin sent a telegram to Turkey's leader, saying that "it is hard to imagine a more cynical crime than killing innocent people during New Year celebrations."

"However, terrorists don't share moral values. Our common duty is to combat terrorists' aggression," Putin said.

The White House condemned what it called a "horrific terrorist attack" and offered U.S. help to Turkey. The U.N. Security Council condemned the "heinous and barbaric" assault in the "strongest terms."

Yildirim, the prime minister, vowed to keep fighting terrorism, adding that "the terror that happens here today may happen in another country in the world tomorrow."

With files from The Canadian Press