Turkish people foiled a coup attempt by a faction of the military. This is the timeline of key events.
This timeline gives a quick recap of all the major events since reports of the attempted coup first surfaced.
The first signs of trouble came on Friday night, when residents in Istanbul began to share pictures over Facebook, Twitter and WhatsApp showing soldiers blocking the Bosphorus and Fatih Sultan Mehmet bridges and diverting traffic.
In the following hours, residents in Istanbul and capital Ankara reported sounds of gunfire, explosions and jets flying through the night sky.
Timeline of Events:
22:29 pm - Istanbul's Bosphorus Bridge and Fatih Sultan Mehmet Bridge are both closed. Dogan News Agency footage shows cars and buses being diverted.
22:50 pm - Noise of gunshots reverberates in Ankara, the capital, where military jets and helicopters are also seen flying overhead. Helicopters fly low in Istanbul as well.
23:02 pm - Prime Minister Binali Yildirim says an attempted coup is under way and calls for calm. He says a group within Turkey's military has attempted to overthrow the government and security forces have been called in to "do what is necessary."
23:25 pm - The Turkish military says it has taken over the country to protect democratic order. In an emailed statement which was reported on Turkish TV channels, the military says all of Turkey's existing foreign relations will be maintained.
23:38 pm - After initial confusion it emerges that Turkish President Recep Tayyip Erdogan is safe.
23:47 pm - The chief of military staff Hulusi Akar among hostages taken at military headquarters in Ankara.
23:49 pm - Presidential source says statement made on behalf of armed forces was not authorised by military command.
23:57 pm - Facebook, Twitter, YouTube and other social media applications are restricted in Turkey.
23:58 pm - Soldiers storm state broadcaster TRT's building in Ankara.
00:02 am - Head of the Istanbul branch of Turkey's ruling AK Party says soldiers entered the party building, instructed him to leave.
00:05 am - Coup plotters announce a new constitution will be prepared, accuse the government of eroding the democratic and secular rule of law. They say the country is being run by a "peace council", that the country is under martial law, and a curfew has been imposed.
00:18 am - Government supporters claim president and government are still in power.
00:22 am - Yildirim says on Twitter everything will be done to put down coup attempt, even if it means loss of lives. Says siege under way at some important buildings but urges people to remain calm.
00:26 am - Erdogan urges people to take to streets to protest against what he describes as a coup attempt by a minority faction within the military. Speaking over Facetime in an interview to a news channel, he says the coup will meet a "necessary response". Says he is returning to Ankara.
00:35 am - Turkish state broadcaster TRT goes off air, but later starts broadcasting from London.
00:51 am - A military helicopter opens fire in Turkish capital Ankara, loud explosions rock the capital.
01:03 am - Justice minister says members of a movement loyal to US-based cleric Fethullah Gulen are behind the attempted coup.
01:08 am - Tanks surround Turkish parliament building, open fire. Gunfire heard at Istanbul airport.
01:37 am - Commander of First Army, part of land forces responsible for Istanbul and other western areas, said those attempting a coup were a small faction and "nothing to worry about."
01:40 am - Special prayers being heard from mosques across Istanbul.
01:47 am - Turkish PM Binali Yildirim says gangs and illegal formations are behind the coup attempt and calls it a terrorist act. He says the government remains in charge. Urges people to take to the streets.
01:51am - Commander of special forces says a group was engaged in treason. Says military does not condone coup.
01:59am - Turkish fighter jet shoots down military helicopter used by coup-plotters over Ankara.
02:04 am - Reports say 17 police killed at Ankara special forces HQ.
02:05 am - US President Barrack Obama says he and Secretary of State Kerry agree that all parties in Turkey should support elected government.
02:13 am - Group close to US-based cleric Fethullah Gulen claims accusations it was involved in coup attempt are "highly irresponsible". Condemns military intervention in Turkish politics.
02:20 am - US Secretary of State John Kerry reasserts Washington's "absolute support for Turkey's democratically elected, civilian government and democratic institutions."
02:39 am - Explosions hit the parliament building in Ankara, injuring many.
03:20 am - Turkish official says Erdogan's plane lands in Istanbul.
03:27 am - Two more explosions hit parliament building. Lawmakers hide in shelter.
03:45 am - Private broadcaster CNN Turk halts live news broadcast, presenter says soldiers entered studio.
03:45 am - Around 30 soldiers, part of the coup, surrender weapons after being surrounded by armed police in Istanbul's central Taksim Square.
04:00 am - Erdogan appears among supporters at Istanbul airport, says uprising has been attempted against their solidarity and unity of the country; says no power is above national will.
04:18 am - An email from the Turkish military General Staff's press office address says the faction of officers behind the coup attempt is still fighting. Ask people to stay indoors.
04:33 am - Supporters of Erdogan attack a group of soldiers who had surrendered. Police intervenes to rescue them. Police officers stand guard near the Turkish military headquarters in Ankara, Turkey, July 15, 2016.
05:10 am - Turkey's military headquarters is now held by pro-government forces but scattered groups of rebel soldiers continue resisting and control some military helicopters. 29 colonels and five generals had been relieved of their duties.
05:29 am - The head of Turkey's armed forces, Hulusi Akar, is rescued after being held hostage.
09:02 am - Turkey's EU minister Omer Celik says coup situation is "90 percent under control," but some commanders are still being held hostage.
09:20 am - Yildirim says 161 people are killed, 1,440 are wounded, 2,839 army members detained including ordinary soldiers and high-ranking officers.
01:20 pm - Erdogan greeted by cheering supporters outside his home.
04:00 pm - Turkish Airlines resume flights from Istanbul's international airport but some delays were expected because of the backlog of passengers who could not fly the previous night.