An attempted Turkish military coup appeared to crumble in the early hours of today after crowds answered President Tayyip Erdogan's urging to take to the streets to support him.
Erdogan, who had been holidaying on the coast when the coup was launched, flew into Istanbul before dawn today and was shown on TV appearing among a crowd of supporters outside the airport, which the coup plotters had failed to secure.
The uprising was an "act of treason", and those responsible would pay a heavy price, he later told reporters at a hastily arranged news conference. Arrests of officers were under way, and it would go higher up the ranks, culminating in the cleansing of the military.
Gunfire and explosions had rocked both the main city Istanbul and capital Ankara in a chaotic night after soldiers took up positions in both cities and ordered state television to read out a statement declaring they had taken power.
But by early today, Reuters journalists saw around 30 pro-coup soldiers surrender their weapons after being surrounded by armed police in Istanbul's central Taksim square.
They were taken away in police vans as a fighter jet repeatedly screeched overhead at low altitude, causing a boom that shook surrounding buildings and shattered windows.
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 one of the most important US allies while war rages on its border. A failed coup attempt could still destabilise a pivotal country.
Before returning to Istanbul, Erdogan appeared in a video call to the studio of the Turkish sister channel of CNN, where an announcer held up a mobile phone to the camera to show him. He urged Turks to take to the streets to defend his government and said the coup plotters would pay a heavy price.
By the early hours of this morning, lawmakers were still hiding in shelters inside the parliament building in Ankara, which had been fired on by tanks. Smoke rose up from nearby, Reuters witnesses said. An opposition MP told Reuters parliament was hit three times and that people had been wounded.
A Turkish military commander said fighter jets had shot down a helicopter used by the coup plotters over Ankara. State-run Anadolu news agency said 17 police were killed at special forces headquarters there.
As the night wore on, momentum turned against the coup plotters. Crowds defied orders to stay indoors, gathering at major squares in Istanbul and Ankara, waving flags and chanting.
"We have a prime minister, we have a chief of command, we're not going to leave this country to degenerates," shouted one man, as groups of government supporters climbed onto a tank near Istanbul's Ataturk airport.
Erdogan and other officials blamed loyalists of a US-based cleric for the coup attempt; his movement denied any part in it.
Helicopter opens fire
The United States declared its firm backing for Erdogan's government. Secretary of State John Kerry said he phoned the Turkish foreign minister and emphasised "absolute support for Turkey's democratically elected, civilian government and democratic institutions".
The coup began with warplanes and helicopters roaring over Ankara and troops moving in to seal off the bridges over the Bosphorus that link Europe and Asia in Istanbul.
Reuters reporters saw a helicopter open fire in Ankara. Anadolu said military helicopters had fired on the headquarters of the intelligence agency.
In the first hours of the coup attempt, airports were shut and access to Internet social media sites was cut off.
Soldiers took control of TRT state television, which announced a countrywide curfew and martial law. An announcer read out a statement on the orders of the military that accused the government of eroding the democratic and secular rule of law. The country would be run by a "peace council" that would ensure the safety of the population, the statement said.
Shortly afterwards, TRT went off the air. It resumed broadcasting in the early hours of today.
Anadolu said the chief of Turkey's military staff was among people taken "hostage" in the capital Ankara, but Prime Minister Binali Yildirim later said he was back in control.
‘Not a tinpot coup’
Early in the evening the coup appeared strong. A senior EU source monitoring the situation said: "It looks like a relatively well orchestrated coup by a significant body of the military, not just a few colonels. They've got control of the airports and are expecting control over the TV station imminently. They control several strategic points in Istanbul.
"Given the scale of the operation, it is difficult to imagine they will stop short of prevailing."
One European diplomat was dining with the Turkish ambassador to a European capital when guests were interrupted by the pinging of urgent news on their mobile phones.
"This is clearly not some tinpot little coup. The Turkish ambassador was clearly shocked and is taking it very seriously," the diplomat told Reuters as the dinner party broke up. "However it looks in the morning, this will have massive implications for Turkey. This has not come out of nowhere."
Turkey, a Nato member with the second biggest military in the Western alliance, is one of the most important allies of the United States in the fight against Islamic State, which seized swathes of neighbouring Iraq and Syria.
The Pentagon said there was no impact on operations against Islamic State from the US air base at Incirlik in Turkey.
Turkey is also one of the main backers of opponents of Syrian President Bashar al-Assad in that country's civil war, host to 2.7 million Syrian refugees and launchpad last year for the biggest influx of migrants to Europe since World War Two.
Celebratory gunfire erupted in Syria's capital Damascus after the army claimed to have toppled Erdogan. People took the streets to celebrate there and in other government-held cities.
Turkey has been at war with Kurdish separatists, and has suffered numerous bombing and shooting attacks this year, including an attack two weeks ago by Islamists at Istanbul's main airport that killed more than 40 people.
Turkish officials blamed the attempted coup on followers of Fethullah Gulen, an influential cleric in self-imposed exile in the United States who once supported Erdogan but became a nemesis. The pro-Gulen Alliance for Shared Values said it condemned any military intervention in domestic politics.
After serving as prime minister from 2003, Erdogan was elected president in 2014 with plans to alter the constitution to give the previously ceremonial presidency far greater executive powers.
Turkey has enjoyed an economic boom during his time in office and has dramatically expanded its influence across the region. But opponents say his rule has become increasingly authoritarian.
His AK Party, with roots in Islamism, has long had a strained relationship with the military and nationalists in a state that was founded on secularist principles after World War One. The military has a history of mounting coups to defend secularism, but has not seized power directly since 1980.
Prime Minister Yildirim said a group within Turkey's military had attempted to overthrow the government and security forces have been called in to "do what is necessary".
"Some people illegally undertook an illegal action outside of the chain of command," Yildirim said in comments broadcast by private channel NTV.
"The government elected by the people remains in charge. This government will only go when the people say so."
Coups and plots in Turkey over past 50 years
On May 2, an almost bloodless military coup was carried out, led by officers and cadets from the Istanbul and Ankara war colleges.
The next day, the commander of land forces, General Cemal Gursel, demanded political reforms and resigned when his demands were refused.
The leaders established a 38-member National Unity Committee with Gursel as chairman. Of 601 people tried, 464 were found guilty. Three former ministers, including Prime Minister Adnan Menderes, were executed and 12 others, including President Celal Bayar, had death sentences commuted to life imprisonment.
1971 - The ‘Coup by Memorandum’
The military delivered a warning to the government to restore order after months of strikes and street fighting between leftists and nationalists.
Some months later, Prime Minister Suleyman Demirel stepped down and a coalition of conservative politicians and technocrats set to restore order under the supervision of the military. Martial law was established in several provinces and not completely lifted until September 1973.
On Sept. 12, 1980, the senior command of the army led by General Kenan Evren, carried out a coup. The action followed a resurgence of street fighting between leftists and nationalists.
Leading politicians were arrested, and parliament, political parties, and trade unions were dissolved. A five-member National Security Council took control, suspending the constitution and implementing a provisional constitution that gave almost unlimited power to military commanders.
1997 - The ‘Post-Modern Coup’
On June 18, 1997 Prime Minister Necmettin Erbakan, denounced by opponents as a danger to the country's secular order, stepped down under pressure from the military, business, the judiciary and fellow politicians. The generals saw themselves compelled to act to defend the secular state founded by Mustafa Kemal Ataturk.
The shadowy Ergenekon group first came to light when a cache of explosives was discovered in a police raid on an Istanbul house. Eventually hundreds of people went on trial for an alleged coup attempt against then-prime minister Tayyip Erdogan, and 275 officers, journalists, lawyers and more were found guilty.
The verdicts were all overturned this year after the appeals court ruled a network called Ergenekon was not proven to exist.
Erdogan, who became president in 2014, initially supported the prosecution but later blamed police and prosecutors who belong to a religious movement led by Fethullah Gulen, who lives in self-imposed exile in Pennsylvania for faking the conspiracy. He denies playing any role.
A newspaper revealed a secularist coup plot, dubbed Sledgehammer, that reportedly dated back to 2003, aimed at fomenting social chaos to topple Erdogan's Islamist-rooted AK Party.
In 2012, a court jailed 300 of the 365 defendants. Two years later, almost all of those convicted were freed after the Constitutional Court ruled their rights had been violated. Again, Gulen's followers were blamed for the case, which they deny.