ISTANBUL — A gunman opened fire at a nightclub in Istanbul filled with New Year’s revelers about an hour after midnight Sunday, killing at least 39 people and injuring scores of others, according to Turkish officials.

Fifteen of the people killed were foreigners, the Foreign Ministry said. They included three Jordanians; a teenager from Israel; a Tunisian couple; a Lebanese man; and a dual citizen of Belgium and Turkey, according to news agencies and government statements.

Sixty-nine people were hospitalized, four of them in critical condition. Among the scores of injured people were citizens of France, Israel, Morocco, Libya and Saudi Arabia.

Interior Minister Suleyman Soylu said the gunman was being sought.

No one immediately claimed responsibility for the mass shooting, which came as threats against Turkey by the Islamic State and its supporters have increased. It was the fourth terrorist attack in Turkey in less than a month.

“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,” President Recep Tayyip Erdogan said in a statement. “We will retain our cool-headedness as a nation, standing more closely together, and we will never give ground to such dirty games.”

He added: “Turkey is determined to continue to fight to the end against terror and to do whatever is necessary to ensure the security of its citizens and secure peace in the region.”

The attack started about 1:15 a.m. at the Reina nightclub, in the Ortakoy neighborhood overlooking the Bosporus. The club is known for its celebrity clientele and its popularity among foreigners. As many as 600 people were celebrating the New Year when a lone attacker, said to be armed with a Kalashnikov rifle, burst in, officials said.

Gov. Vasip Sahin of Istanbul Province said a police officer outside the club had been killed before the bloodshed began inside.

“One person first kills the police officer outside, and then a civilian,” Mr. Sahin said. “Inside, he rained bullets brutally, mercilessly over innocent people who were there just to celebrate the New Year and have fun.”

In the ensuing panic and the rush to escape, some clubgoers jumped into the Bosporus — which separates Europe and Asia — and others hunkered down for safety.

Sinem Uyanik, who was there with her husband, Lutfu Uyanik, told The Associated Press that she had seen several bodies inside the club. Her husband was wounded, she added, but not seriously.

“Before I could understand what was happening, my husband fell on top me,” she said. “I had to lift several bodies from on top of me before I could get out.”

A wounded man on a stretcher told the independent Turkish news agency DHA that the attacker had “put a bullet to the head of anyone alive.”

Television footage showed dozens of ambulances rushing to the scene and people fleeing, some walking with difficulty, arm in arm.

The owner of Reina, Mehmet Kocarslan, told that security measures had been beefed up over the past 10 days after American intelligence officials had warned about an attack in Turkey over the holidays.