Operations involving police special forces and the military were still underway to regain control of the armed forces headquarters in Ankara
Forces loyal to the Turkish government fought on Saturday to crush the remnants of a military coup attempt which crumbled after crowds answered President Tayyip Erdogan's call to take to the streets and dozens of rebels abandoned their tanks.
Ninety people were killed, including many civilians after a faction of the armed forces tried to seize power using tanks and attack helicopters. Some strafed the headquarters of Turkish intelligence and parliament in the capital, Ankara, and others seized a major bridge in Istanbul.
Erdogan appeared to accuse the coup plotters of trying to kill him and said he would purge the armed forces, which in the past have staged a number of successful coups, although not for more than 30 years.
"They will pay a heavy price for this," he said. "This uprising is a gift from God to us because this will be a reason to cleanse our army." Later, the presidency warned on Twitter that another uprising could be staged at any time.
Turkish authorities have already detained about 1,500 members of the armed forces, officials said. The chief of staff, who had been reported held hostage by the rebels, has been rescued, a senior official said.
A successful overthrow of Erdogan, who has ruled Turkey since 2003, would have marked one of the biggest shifts in the Middle East in years, transforming a major U.S. ally while war rages on its border.
However, a failed coup attempt could still destabilise a NATO member that lies between the European Union and the chaos of Syria, with Islamic State bombers targeting Turkish cities and the government also at war with Kurdish separatists.
Erdogan, who had been holidaying on the southwest coast when the coup was launched, flew into Istanbul before dawn on Saturday and was shown on TV outside Ataturk Airport.
Addressing a crowd of thousands of flag-waving supporters at the airport later, Erdogan said the government remained at the helm, although disturbances continued in Ankara.
Erdogan, whose Islamist-rooted ideology lies at odds with supporters of modern Turkey's secular principles, said the plotters had tried to attack him in the resort town of Marmaris.
"They bombed places I had departed right after I was gone," he said. "They probably thought we were still there."
The acting armed forces chief of staff, Umit Dundar, reported heavy casualties. Among the 90 dead were 47 civilians while a further 1,154 people had been wounded.
In a live statement broadcast on CNN Turk, Dundar said many military commanders have been taken hostage by the rebels but he declared that Turkey has "closed the chapter" on coups for good.
Erdogan's AK Party, with roots in Islamism, has long had a strained relationship with the military and nationalists. The armed forces have had a history of mounting coups to defend secularism, but have not seized power directly since 1980.
Operations involving police special forces and the military were still underway to regain control of the armed forces headquarters in Ankara, one official said.