An attempted coup by a faction of the armed forces has been quashed, Turkey's acting military chief of staff says.
Umit Dundar said 104 coup plotters had been killed and 1,563 arrested in a night of gunfire and explosions in Ankara, Istanbul and elsewhere.
A further 90 people died and 1,154 people were injured as thousands of Turks heeded President Erdogan's call to rise up against the coup-plotters. It is not yet known who was behind the attempted putsch.
President Recep Tayyip Erdogan blamed a "parallel structure", in a clear reference to Fethullah Gulen, a powerful but reclusive US-based Muslim cleric he accuses of fomenting unrest.
However, in a statement, Mr Gulen rejected any suggestion he had links to the events, saying he condemned "in the strongest terms, the attempted military coup in Turkey".
Events began on Friday evening when tanks took up positions on two bridges over the Bosphorus Strait in Istanbul, blocking it to traffic. Troops were seen on the streets and low-flying military jets were filmed over Ankara. 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.
In a speech at Istanbul airport, Mr Erdogan said: "What is being perpetrated is a treason and a rebellion. They will pay a heavy price."
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 headquarters and tanks were said to be stationed outside Istanbul airport.
Broadcaster CNN Turk was temporarily taken off air after soldiers entered the building and tried to take it over. CNN Turk later tweeted a photo of soldiers being arrested by police.
Mike Baddeley, on holiday in Marmaris, said he was woken by "a very large explosion, followed by, it seemed like one or two helicopters flying above our heads... with machine gun fire".
In the morning, he saw armed men in military fatigues walking around the hotel, but no further violence.
There were reports of fierce clashes in Taksim Square in the centre of Istanbul, and gunfire and explosions were heard near the square.
One of the helicopters being flown by rebels was shot down by government troops in Ankara.
Sporadic gunfire was still being reported in some areas by morning.
What is happening now?
The situation was still confused on Saturday, but Gen Dundar said the coup attempt "has been foiled".
He said 47 civilians, 41 police officers and two soldiers had been killed in the violence, and many commanders were taken to "unknown locations".
Around 200 unarmed soldiers have left Turkey's military headquarters in the capital Ankara and surrendered to police, the state-run Anadolu news agency says.
Earlier, 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.
In Washington, President Barack Obama urged all parties in Turkey to support the "democratically elected government".
Nato, of which Turkey is a member, 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" and called for a "swift return to Turkey's constitutional order".
Russia said it was deeply concerned, saying "the flare-up of the domestic political situation against the backdrop of the existing terrorist threats in this country and the armed conflict in the region brings a heightened risk to international and regional stability".
SDR reading between the lines
Iran said events in Turkey proved "that a coup d'etat has no place and is doomed to fail in our region".
Hinting out that the rebellion was foreign maid (Western) Basically blaming US and Israel ....
Taking a closer look at Turkey´s Edogan
Recep Tayyip Erdogan's AK Party enjoys a fierce and loyal support among Turkey's conservative, Muslim base, while outside the country outrage grows over his silencing of critics, often by force.
Turkish journalists have been investigated and put on trial, foreign journalists have been harassed and deported. Last month, police raided Turkey's biggest newspaper, Zaman. Its staff emerged bloodied and cowed.
Zaman's last independent edition said Turkey's press had seen one of its "darkest days". Its first edition under state control carried unabashedly pro-government articles.
And Mr Erdogan's authoritarian approach is not confined to Turkey's borders. His bodyguards harassed reporters in the US, and a German satirist is under investigation in his home country for offending the Turkish president on TV.
Mr Erdogan, 61, came to power in 2002, a year after the formation of the AK Party. He spent 11 years as Turkey's prime minister before becoming the country's first directly-elected president in August 2014 - a supposedly ceremonial role.
In June 2015 the AK Party suffered a dip in the polls and failed to form a coalition. But a snap election in November, after Turkey's worst suicide bombing prompted Mr Erdogan to escalate his war against the PKK, gave the party a convincing majority.
Challenging the military
In the decades before the AKP's rise to power, the military had intervened in politics four times to curb Islamist influence.
In 2013 Mr Erdogan triumphed over the military elite when senior officers were among 17 people jailed for life, convicted of plotting to overthrow the AKP in what was known as the "Ergenekon" case.
Hundreds of other officers were also put on trial, along with journalists and secularist politicians, in that investigation and a similar one called the "Operation Sledgehammer" case.
When more than 200 officers were detained in the Sledgehammer investigation in 2011, the heads of Turkey's army, navy and air force resigned in protest.
Critics accused Mr Erdogan of using the judiciary to silence political opponents, and there were many allegations of trumped-up charges.
But his supporters applauded him for taking on previously untouchable establishment figures, who saw themselves as guardians of the state created by Mustafa Kemal Ataturk.
Gezi Park protests
Mr Erdogan also unleashed the power of the state to crush mass protests in Istanbul in June 2013, focused on Gezi Park, a green area earmarked for a huge building project.
The protests spread to other cities, swelled by many secularist Turks suspicious of the AKP's Islamist leanings.
A major corruption scandal battered his government in December 2013, involving numerous arrests, including the sons of three cabinet ministers.
Mr Erdogan raged against "plotters" based outside Turkey, condemning supporters of Fethullah Gulen. He also lashed out against social media, vowing to "wipe out" Twitter.
He has a combative charisma that many Turks in the teeming cities and small Anatolian towns love.
But his reputation took a hit in May 2014 when he reacted coldly to a mine disaster in Soma, western Turkey, which killed 301 people.
Mr Erdogan has denied wanting to impose Islamic values, saying he is committed to secularism. But he supports Turks' right to express their religious beliefs more openly.
That message goes down particularly well in rural and small-town Anatolia - the AKP's traditional heartland. Some supporters nicknamed him "Sultan" - harking back to the Ottoman Empire.
In October 2013 Turkey lifted rules banning women from wearing headscarves in the country's state institutions - with the exception of the judiciary, military and police - ending a decades-old restriction.
Mr Erdogan's wife Emine wears a headscarf to official functions, as does the wife of his long-standing AKP ally Abdullah Gul, who was president before him.
Critics also pointed to Mr Erdogan's failed bid to criminalize adultery, and his attempts to introduce "alcohol-free zones", as evidence of his alleged Islamist intentions.
Mr Erdogan's political opponents saw a lavish new presidential palace as a symbol of his alleged authoritarian tendencies.
Perched on a hill on the outskirts of Ankara, the 1,000-room Ak Saray (White Palace) is bigger than the White House or the Kremlin and ended up costing even more than the original £385m ($615m) price tag.
Mr Erdogan owes much of his political success in the past decade to economic stability, with an average annual growth rate of 4.5%.
Turkey has developed into a manufacturing and export powerhouse. The AKP government kept inflation under control - no mean feat, as there were years in the 1990s when it soared above 100%.
But in 2014 the economy began flagging - growth fell to 2.9% and unemployment rose above 10%.
On the international stage he has bitterly condemned Israel - previously a strong ally of Turkey - over its treatment of the Palestinians. The policy not only galvanized his Islamic base, but also made him a hugely popular leader across the Middle East. He has backed Syria's opposition in its fight against Bashar al-Assad's government in Damascus.
But his tentative peace overtures to the Kurds in south-eastern Turkey soured when he refused to help Syrian Kurds battling Islamic State militants just across the border.
Fanatic Islamic education
Born in 1954, Recep Tayyip Erdogan grew up the son of a coastguard, on Turkey's Black Sea coast.
When he was 13, his father decided to move to Istanbul, hoping to give his five children a better upbringing. As a teenager, the young Erdogan sold lemonade and sesame buns on the streets of Istanbul's rougher districts to earn extra cash.
He attended an Islamic school before obtaining a degree in management from Istanbul's Marmara University - (And playing professional football.)
While at university, he met Necmettin Erbakan - who went on to become the country's first Islamist prime minister - and entered Turkey's Islamist movement.
In 1994, Mr Erdogan became the mayor of Istanbul. Even his critics admit that he did a good job, making Istanbul cleaner and greener. Some think he should have stayed Mr green finger as his Islamist ambitions mixed with Ottoman superiority and nationalism has moved Turkey away from the west....
Lets not forget that in 1999 he spent four months in jail after a conviction for religious incitement.
He had publicly read a nationalist poem including the lines: "The mosques are our barracks, the domes our helmets, the minarets our bayonets and the faithful our soldiers."
In 2001 Mr Erdogan launched the AKP with allies, having broken away from the Virtue Party, which had been banned.
His rise to power was complete when the AKP won a landslide election victory in 2002 and he became prime minister.
Erdogan and radicalism
Turkish President Recep Tayyip Erdogan’s flirtation with radical Islam in Syria and march from liberal democratic reformer to illiberal populist authoritarian have confused Americans trying to deal with Turkey, which is a nominal U.S. ally and a member of NATO. But it’s important to remember that Erdogan has pursued these risky policies very deliberately, and now, once again, they have literally blown up in his face. The suicide bomber that struck the tourist heart of Istanbul on Tuesday is said to be of Syrian origins, a case of potential blowback from Erdogan’s risky adventures in Syria that have seen Turkish authorities turn a blind eye to Islamist activity on its southern border.
Since he took over as president in 2014, Erdogan has abandoned Turkey’s traditional pragmatism in favor of an Islamist ideological agenda that led to an open-door policy toward neighboring Syria; a relaxed policy directed at militants fighting Bashar al-Assad in turn resulted in the appearance of radical jihadists such as ISIL on Turkey’s doorstep, the same jihadists who today allegedly sent a suicide bomber to kill scores of tourists in Istanbul.
Erdogan’s support for the Muslim Brotherhood regionally, pursuit of sectarian policies, and his dangerous dance with radical Islam has not only added to regional instability and jeopardized U.S. interests, it has also plainly harmed Turkey’s security and economic prospects (the majority of the victims of Turkeys bombing were reportedly German tourists).
Yet Erdogan remains determined to pursue his stealthy regional agenda, even as the casualty toll from terror mounts.
The Turkish president’s actions in Syria are founded on his devotion to a Turkish interpretation of Muslim Brotherhood principles. In Syria, Erdogan first pushed for reform to expand Sunni influence at the expense of Assad’s Alawites. When that campaign failed, he doubled down on his efforts to make Syria a Sunni-led state, and not coincidentally curb the political power of the ethnic Kurds, who make up a substantial minority in Turkey, by reaching out to even extreme Sunni Islamist elements.
While Erdogan’s contradictions may appear to be the result of improvisation, opportunism and even overreaction by a thin-skinned politician, interesting connections exist that frame a coherent philosophy. Erdogan’s power-driven and Islamist-oriented regional policy is consistent with his approach on the domestic front. The first truth is Erdogan’s extreme disdain toward democratic political constraints. To Erdogan, constitutions and laws can be ignored, subordinate to his persona, and regarded as potential obstacles. Despite some opposition even within his own party, the Justice and Development Party (shortened to AKP in Turkish), he maintains a majoritarian view, which he believes provides him a carte blanche to essentially do as he sees fit.
This attitude seems to be part and parcel of his entire life. His family hailed from a humble background, and he spent his youth in the poor Kasımpaşa district of Istanbul. As a young man, he attended a religious Imam Hatip school, never learned English and had little or no overseas experience.
Like any underdog, Erdogan developed a conviction that he had to fight the established structures in order to succeed. This conviction only hardened as the traditional parties and Turkish state tried repeatedly to destroy his political career. In his view, the Turkish establishment gave him no quarter, and he gives them none in return.
The second component of Erdogan’s mind-set is the Millî Görüş Islamist movement, which has its roots in the Muslim Brotherhood and forms his core political philosophy.
It is the product of Necmettin Erbakan, former prime minister and Erdogan’s longtime mentor, and was one of the foundations of Erbakan’s National Salvation Party, the first party Erdogan was politically involved in, and the Welfare Party that Erdogan belonged to as mayor of Istanbul.
Most notably, Erdogan and Erbakan shared a belief in “street Islam,” a populist twist on the more theocratic political Islam of the time, emphasizing the role of the people, rather than institutions, as the backbone of political power.
From this perspective, Erdogan’s approach to power has been consistent, despite his government’s insistence that the AKP is not Islamist. As we look back, Erdogan’s composite outlook suggests that he did not intend to be a reformer. Under cover of a reform agenda, he consolidated power in the early 2000s by abolishing the state security courts, reducing the military’s status and decreasing government regulation of religion.
The pursuit of membership in the European Union also provided a positive framework for these reforms, but Erdogan’s aim was not a more pluralistic democracy!
While the AKP government did bring the military under civilian control and revived the economy, the overall effect was to adroitly neutralize the education, military and judicial institutions capable of acting as a check on state power. Much has happened since the Arab Spring to challenge Erdogan’s domestic and foreign policies.
Domestically, while he has won a new mandate to seek the constitutional change to cement his political control, he has done so at the cost of a growing Kurdish insurgency and the elimination of media freedom. His disregard for institutional controls on government and belief in populist justification for authoritarian rule has deepened internal tensions.
Regionally, his missteps in Syria, from which Turkey is now experiencing the consequences — compare unfavorably with Turkey’s historically pragmatic approach and highlight risky and ideological tactics that are failing. His devotion to his original philosophy has brought him great political successes, but the costs continue to mount for him, for the Turkish people and for stability in the region.