Armed with a long-barrelled weapon, the attacker shot a police officer before storming the elite Reina club in the Ortakoy area of the city at about 1.45am.
"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," Istanbul Governor Vasip Sahin said, describing the carnage as a "terror attack".
Turkish Interior Minister Suleyman Soylu said the gunman was still at large. "The search for the terrorist continues... Our security forces have started the necessary operations. God willing he will be caught in a short period of time."
Raising the death toll to 39, Mr Soylu said that of 21 victims who had been identified so far, 16 were foreigners and five were Turks. Another 69 people were being treated in hospital for their wounds.