Turkey on Wednesday said it had identified the gunman who slaughtered 39 people in an Istanbul nightclub --but the country's foreign minister wouldn't name the killer, who continued to elude the nation's dragnet.

Turkish media has twice published incorrect names or pictures of a possible suspect in the days since the early Sunday attack at Reina, which could be contributing to the government's cautious approach this time.

"The identity of the person who carried out the attack on the Reina nightclub has been established," Foreign Minister Mevlut Cavusoglu told state-run news agency Anadolu in a live televised interview.

Turkish police, meanwhile, detained at least five suspected ISIS militants believed to be linked to the attack during an operation in the Aegean port city of Izmir, Anadolu reported.

ISIS has claimed responsibility for the attack, which also wounded nearly 70 people. Of those killed, 27 were foreigners, many from the Middle East. ISIS said a "soldier of the caliphate" had carried out the mass shooting to avenge Turkish military operations against the terror group in northern Syria.

President Recep Tayyip Erdogan said that the attack aimed to set Turks against each other and deepen fault lines.

Erdogan made the comments during a live speech from Ankara, the first time he had publicly addressed the nation since the attack.

Responding to accusations in the past that Turkey had given support to ISIS, Erdogan said that "to present the country which is leading the greatest struggle against [ISIS] as one supporting terrorism is what the terror organization wants."

Erdogan said "in Turkey, no one's way of life is under any threat. Those who claim this have to prove it. It is my duty to protect everyone's rights."

He added: "To say Turkey has surrendered to terrorism is to take sides with the terrorists and terror organizations."

Police in Istanbul have set up checkpoints and were checking vehicles across the city as security levels remained high. Police were stopping cars and Istanbul's ubiquitous yellow taxis, with passengers and drivers holding up their identifications while officers inspected inside the vehicles. Istanbul has been on high alert since the attack, with the gunman still at large. The killer had used a taxi to get to and from the nightclub on the morning of the attack.

The private Dogan news agency said that Wednesday's police operation targeted three families who had arrived in Izmir about 20 days ago from Konya — a city in central Turkey where the gunman is thought to have been based before carrying out the nightclub attack. It said 27 people, including women and children, were taken into custody.

At least 14 people were previously detained in connection with the attack, including two foreigners stopped Tuesday at the international terminal of Istanbul's Ataturk Airport after police checked their cellphones and luggage, according to Anadolu.

Turkish media reports claimed Tuesday that the gunman's wife was in custody and had told police she didn't know her husband was linked to ISIS. An eerie selfie video emerged of the alleged gunman on Tuesday, showing him silently touring Istanbul's most famous square. The camera never leaves the man's unsmiling face as he walked through Taksim Square during the 44-second clip that was broadcast on state-run Anadolu television and other Turkish media.