President Recep Tayyip Erdogan urged Turks to remain on the streets on Saturday, as his forces regained control after a spectacular coup bid by discontented soldiers that claimed more than 250 lives.
After hours of chaos and violence unseen in decades, Erdogan ended uncertainty over his whereabouts, flying into Istanbul airport in the early hours where he was cheered by hundreds of supporters.
"The situation is completely under control," Prime Minister Binali Yildirim said outside his Ankara offices, flanked by Turkey's top general.
Erdogan used his Twitter feed to urge people onto the streets, warning against a new flare-up after the most dramatic challenge to his 13 years of dominant rule.
"We should keep on owning the streets tonight no matter at what stage (the coup attempt is) because a new flare-up could take place at any moment," he said.
Soldiers and tanks took to the streets late Friday and multiple explosions rang out throughout the night in Ankara and Istanbul, the two biggest cities of the strategic NATO member of 80 million people.
Describing the attempted coup as a "black stain" on Turkey's democracy, Yildirim said that 161 people had been killed in the night of violence and 1,440 wounded.
This did not appear to include 104 rebel soldiers killed overnight, in a toll given by the military.
As the dust settled on a dramatic and chaotic night, TV pictures Friday showed extensive damage to the parliament building in Ankara that was bombed by rebel jets.
Crowds of flag-waving supporters of Erdogan's ruling Justice and Development Party (AKP) appeared to have turned the tide, defying orders of a curfew and marching out onto the streets to block the attempt to overthrow the regime.
Yildirim said the putsch bid had fallen apart as nearly 3,000 soldiers suspected in involvmenet were detained.
The strongman denounced the coup attempt as "treachery", saying he was carrying out his functions and would keep on working "to the end".
"What is being perpetrated is a treason and a rebellion. They will pay a heavy price for this act of treason," Erdogan said at the airport. "We will not leave our country to occupiers."
Erdogan's critics have long accused him of undermining modern Turkey's secular roots and of sliding into authoritarianism — but the president was believed to have won control of the military after purging elements who opposed him.
Erdogan immediately pinned the blame on "the parallel state" and "Pennsylvania" — a reference to Pennsylvania-based cleric Fethullah Gulen, his arch-enemy whom he has always accused of seeking to overthrow him.
But the president's former ally "categorically" denied any involvement in the plot, calling the accusation "insulting".