President Recep Tayyip Erdogan battled to regain control over Turkey on Saturday after a coup bid by discontented soldiers, as signs grew that the most serious challenge to his 13 years of dominant rule was faltering.
After hours of chaos and violence unseen in decades, Erdogan ended uncertainty over his whereabouts, flying into Istanbul airport in the early hours and making a defiant speech cheered by hundreds of supporters.
Soldiers and tanks took to the streets late on 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.
After a night of drama and bloodshed, some 265 people have been killed in clashes and 2,800 military personnel arrested, officials said. The death toll included more than 100 coup plotters, said acting military chief, Gen. Umit Dundar. At least 1,440 people were wounded, officials said.
Crowds of flag-waving supporters of Erdogan's ruling Justice and Development Party 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.
'Treason and rebellion'
Erdogan 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."
Turkey's parliament, which had been targeted by coup plotters and received extensive damage, was meanwhile holding an extraordinary session, broadcast live on television, while special forces were reportedly securing the headquarters of the military chief of staff.
Dozens of soldiers backing the coup surrendered on the Bosphorus bridge in Istanbul they had held throughout the night, holding their hands above their heads as they were detained, television pictures showed.
Read more: A brief history of coups in NATO nations
There was chaos in Istanbul as angry crowds took to the streets to boo the passing tanks, with smaller numbers welcoming the troops.
As a helicopter flew over the famed Taksim Square, scene of massive anti-Erdogan protests three years ago, the crowd began to boo, shaking their fists at the night sky before they were shot at by the soldiers.
"The people are afraid of a military government," a 38-year-old man who gave his name as Dogan told AFP. "Most of them have been in military service, they know what a military government would mean."
The sound of F-16 fighter jets screaming low over the capital Ankara signalled the start of the putsch late Friday, with troops also moving to block the two bridges across the Bosphorus Strait in Istanbul.
As protesters took to the streets, an AFP photographer saw troops open fire on people gathered near one of the bridges, leaving dozens wounded.
Soldiers also shot at protesters angrily denouncing the coup bid at Istanbul's Taksim Square, injuring several.
Turkish army F-16s launched air strikes against tanks stationed by coup backers outside the presidential palace in Ankara, while the parliament was also bombed, leaving its offices wrecked.
Regular explosions could be heard from the AFP office situated near the complex.
World leaders called for calm, with President Barack Obama and other Western countries urging support for the government they said had been democratically elected.
The attempted coup brought new instability to the Middle East region, with Turkey a key powerbroker in the ongoing Syria conflict.
In a key moment in the standoff, Turkish security forces rescued the country's top army general, Hulusi Akar, who had reportedly been taken hostage in the earlier stages of the coup bid.
Istanbul authorities sought to make a show of normalisation with the bridges reopening to traffic and Ataturk International Airport — which had been shut down by the plotters — gradually reopening.
Coup bid 'to restore order'
After the initial dramatic military movements, state broadcaster TRT said the troops behind the putsch had declared martial law and a curfew, in a statement signed by a group calling itself the "Council for Peace in the Homeland."
It said the coup had been launched "to ensure and restore constitutional order, democracy, human rights and freedoms and let the supremacy of the law in the country prevail, to restore order which was disrupted."
No named military officer claimed responsibility for the actions although Prime Minister Binali Yildirim claimed a key pro-coup general had been killed.
Turkey's once-powerful military has long considered itself the guardian of the secular state founded by Mustafa Kemal Ataturk in 1923.
It has staged three coups since 1960 and forced out an Islamic government in 1997.
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.
But some Turks were welcoming news of the coup attempt.
"Turks are on fire," Fethi, a 27-year-old tour guide in Taksim Square, told AFP.
"We have hope now," he added. "Turkey has been in a very polarized state for almost 15 years now ... This is the manifestation of all that anger."
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".
World leaders rushed to urge calm with EU foreign policy chief Federica Mogherini calling for "restraint and respect for democratic institutions".
Obama has been briefed, while the Kremlin said it was "deeply concerned" by the developments.
"Everything must be done to protect human lives," said a spokesman for German Chancellor Angela Merkel.