The attack happened at Reina nightclub early on Sunday, as people gathered to mark the new year.
According to the BBC, officials say some 15 foreigners were killed, including citizens from Israel, France, Tunisia, Lebanon, India, Belgium, Jordan and Saudi Arabia.
The attacker left his gun before “taking advantage of the chaos” and fleeing the scene, Turkey’s PM said.
Binali Yildirim also confirmed the gunman was not dressed as Santa Claus, contradicting earlier reports.
The attack unfolded some 75 minutes into the new year as around 700 people gathered in the waterside Reina club, one of Istanbul’s most upmarket venues.
The attacker shot dead a policeman and a security guard at the entrance before heading into the club, which is popular with celebrities and foreigners.
Eyewitnesses described seeing dozens of bodies lying on the floor. Some revellers reportedly threw themselves into the Bosphorus to escape the carnage.
A professional footballer, Sefa Boydas, told AFP news agency that people appeared to be crushed as they ran away. “They say 35 to 40 died but it’s probably more because when I was walking, people were walking on top of people.”
According to CNN, an eyewitness, Yunis Turk, explained after police secured the Reina nightclub: “We were having fun, at first we thought it was a fight then there was a lot of gunfire.
“After the gunfire everyone started to run toward the terrace. We ran as well. There was someone next to me who was shot and fell on the floor. We ran away and hid under the sofas.
Some people jumped into the Bosporus, he said, a testament to the panic that engulfed the nightspot – it is freezing in Istanbul but people were willing to leap into the frigid water to escape the panic.
“For ten minutes there was gunfire and then for another five minutes they were throwing bombs, fired a bit more, then left,” Turk recalled.
Turkish Deputy Prime Minister, Numan Kurtulmus, also told CNN that the attacker was a lone assailant and that the authorities “are trying hard” to identify and apprehend the person in order to investigate any ties to terror groups.
In his new year message, Pope Francis condemned the shooting, describing it as unfortunate.
“Unfortunately, violence has once again struck on this night of hope and dreams.
“With sadness, I express my solidarity with the Turkish people.
“I pray for the numerous victims and injured and for all countries at war,” the Pope said.
Residents have continued to lay flowers outside the nightclub.