Scores of people have been killed in Turkey and more than 1,400 wounded as a result of an attempted coup overnight. But who was responsible, what happened and why?
How did it start?
Bridges over the Bosphorus strait in Istanbul were blocked by troops late evening local time on Friday. Fighter jets and helicopters were seen flying over the Turkish capital, Ankara, and gunshots heard.
Soon after, Prime Minister Binali Yildirim announced that an attempt to overthrow the government was under way.
A faction of the army then said, via a state broadcaster, that it had seized power to protect democracy from President Recep Tayyip Erdogan.
A curfew, martial law and the preparation of a new constitution was announced. Mr Erdogan, who was on holiday in a seaside resort town, called on his supporters to take to the streets in protest and returned to Istanbul.
Over the course of a violent night, TV stations were raided by soldiers, explosions heard in Istanbul and Ankara, protesters shot at, the parliament and presidential buildings fired upon, a military helicopter shot down and the Turkish military chief taken hostage.
How did it end?
For the plot to succeed, the army faction needed public support or wider military backing. Neither materialised. Opposition parties also condemned the coup.
In the early hours of Saturday morning, groups of soldiers involved began to surrender. Troops abandoned their tanks with their hands up.
Security forces also took back key installations and bases, including the military headquarters.
By Saturday evening, some of the same places that had seen such chaos the night before were filled with jubilant supporters of Mr Erdogan.
Who was responsible?
It remains unclear.
The government has blamed Fethullah Gulen, a powerful, reclusive US-based Muslim cleric whom it accuses of fomenting unrest. Mr Gulen denied the claims and has condemned the coup.
Meanwhile, the government has arrested some 6,000 people, including high-ranking soldiers and judges.
Some soldiers have claimed to have been told they were taking part in military exercises and did not know a coup was being attempted, media reports say.
Why would they have done it?
The Turkish army has historically intervened in politics as it sees itself as the protector of Turkey's secularism and democracy - there have been four military coups since 1960.
The military has had tensions with Mr Erdogan's Justice and Development Party (AKP) over its brand of political Islamism. The president has also cracked down on free media and is seen as an authoritarian by many people.
BBC Middle East Editor Jeremy Bowen also suggests the war in neighbouring Syria and its spill over effects on Turkey, including jihadist attacks, may have been a factor.
What has the response been outside Turkey?
As events unfolded, international powers appealed for calm and said Turkey's democratic institutions must be respected.
Turkey is a leading Nato member, plays a key role in the Syrian conflict, and for the EU is an important partner in its attempts to solve the migrant crisis, so any upheaval has major consequences.
Is it still safe to travel to Turkey?
The US advises its citizens to reconsider travelling at this time, while the UK Foreign Office warns of a "potentially volatile" security situation.
After heavy disruption, flights are returning to normal. If you have travel plans involving Turkey, check with your airline or tour operator.