Turkish President Recep Tayyip Erdogan has denounced a coup attempt as an "act of treason" and insisted his government remains in charge.
A faction of the armed forces is accused of trying to seize power, after a night of gunfire and explosions in Ankara and Istanbul.
Officials say the coup attempt is over, although the situation is still confused.
At least 90 people are dead and more than 1,000 wounded. Some 1,563 soldiers have been arrested.
Dramatic images showed dozens of soldiers walking away from their tanks with their hands up on one of Istanbul's Bosphorus bridges, after they had closed it off to traffic all night.
Events began on Friday evening when tanks took up positions on key bridges in Istanbul, blocking it to traffic. Troops were seen on the streets and low-flying military jets were filmed over Ankara, the capital.
Shortly after, a faction of the army released a statement saying that a "peace council" was running the country, and there would be a curfew and martial law.
The group said it had launched the coup "to ensure and restore constitutional order, democracy, human rights and freedoms".
It said that the democratic and secular rule of law had been eroded by the current government, and there would be a new constitution.
President Erdogan was in the south-west holiday resort of Marmaris at the time. He made a televised address, via his mobile phone, urging people to take to the streets to oppose the uprising.
He then flew on to Istanbul, saying Marmaris had been bombed after he left.
Prime Minister Binali Yildirim in Ankara ordered the military to shoot down aircraft being used by coup plotters.
The army's top general and military chief of staff, Hulusi Akar, was reportedly taken hostage by the coup-plotters, and then released.
Outbreaks of violence
The Turkish parliament and presidential buildings in Ankara were attacked. At least one bomb hit the parliament complex. MPs were believed to be hiding in shelters.
Gunfire was also heard outside Istanbul police HQ and tanks were said to be stationed outside Istanbul airport.
Broadcaster CNN Turk was reportedly taken over by soldiers, and its live broadcast was cut.
Many people heeded Mr Erdogan's call and took to the streets to confront the coup-plotters.
There were reports of clashes in Istanbul's Taksim Square, and gunfire and explosions heard near the square.
One of the helicopters being flown by rebels was shot down in Ankara.
Sporadic gunfire was still being reported in some areas by morning.
What is happening now?
The situation is still confused, but Turkey's foreign ministry said the coup attempt had been "foiled by the Turkish people in unity and solidarity. Our president and government are in charge".
Istanbul's main Ataturk airport is now under army control, and flights - which had been interrupted for some hours - were due to resume from 06:00 (03:00 GMT).
Dramatic images of the surrender of one unit of 60 soldiers on one of Istanbul's bridges was shown live on TV on Saturday morning.
It is not yet known who was behind the coup. Turkey said it was a "clique within the armed forces" who carried out the attempt.
President Erdogan blamed a "parallel structure" for the coup attempt.
He has used this term in the past to refer to Fethullah Gulen, a US-based Muslim cleric he accuses of fomenting unrest.
However, in a statement, Mr Gulen rejected any suggestion he had links to the events.
"I condemn, in the strongest terms, the attempted military coup in Turkey," he said.
In Washington, US President Barack Obama urged all parties in Turkey to support the "democratically elected government".
Nato called for "full respect" for Turkey's democratic institutions.
European Council President Donald Tusk said the country was "a key partner for the European Union".
"We call for a swift return to Turkey's constitutional order," he added.
Turkey's military coups
1997 - also known as "post-modern coup". Turkish military intervention leads to resignation of Islamist prime minister Necmettin Erbakan.
1980 - Military coup following armed conflict between right-wing and left-wing groups in the 1970s
1971 - Military coup known as the "coup by memorandum", which the military delivered instead of sending out tanks
1960 - Coup by group of young military officer outside chain of command, against the democratically-elected Democrat Party