By Samia Nakhoul and Nick Tattersall

ISTANBUL (Reuters) - Turkish President Tayyip Erdogan, whose fate was in the balance as rebel soldiers tried to topple him, has triumphed against his enemies and quickly reasserting his grip on power. But the failed military coup is further polarizing a nation in turmoil.

The upheaval following the attempted putsch on Friday night is far from over. It has traumatized the nation and caused irreparable damage to a military seen as a bedrock of stability in a country fighting Islamic State and a Kurdish insurgency.

"In the end, Erdogan and his supporters won the day (but)nobody in Turkey has won in the long-term," wrote Hugh Pope and Nigar Goksel of the International Crisis Group. They predicted that "damage to the army – more important than ever, given the turmoil in Turkey’s neighborhood – will be severe."

The move by a faction inside the army triggered an eruption of nationalist and Islamist feeling in support of Erdogan that has emboldened the government to unleash a crackdown. Thousands of opponents have been purged from the army and courts, universities and the civil service.

Erdogan and the ruling AK Party, its roots in Islamist politics, accuse Turkish cleric Fethullah Gulen, a former ally turned bitter rival, of orchestrating the plot and have called for his extradition from the United States. Erdogan's spokesman said a formal request was being drawn up.

Some 35,000 members of the army, police, judiciary, and civil service have been detained or suspended on suspicion of Gulenist links since the abortive coup, during which more than 230 people were killed.

The purge extended to the education sector on Tuesday, with all university deans ordered to resign, according to state TRT television, and the licenses of 21,000 private school teachers revoked. Private schools in Turkey and abroad had long provided Gulen's movement with new recruits and financing.

Around 1,400 people were wounded as soldiers commandeered tanks, attack helicopters and warplanes in their bid to seize power, strafing parliament and the intelligence headquarters and trying to seize the main airport and bridges in Istanbul.

"This is a trauma and like all traumas it is going to color everything that comes next," said Hakan Altinay of Washington's Brookings Institution. "It certainly helps Erdogan, who has been talking about the Gulenists' sinister plots for a long time, and now there is a plot more sinister than he could have thought."

The purges already appear to be going beyond Gulen's purported followers.

"I'm sure they are going to use this incident to mop up other undesirables as well. What happened is so grave that they don't need any extra fuel, just the act itself is galvanizing enough," Altinay said.

The speed and size of the clampdown, along with calls to reinstate the death penalty for the plotters, is causing alarm among Western allies who are insisting Ankara must uphold the rule of law in the country, a NATO member and European Union candidate state that is Washington's most powerful Muslim ally.

It is unlikely, analysts say, that such calls will be heeded. The failed coup shook the leadership to the core and came close to eliminating Erdogan and other top figures.


Some Turkey analysts say that Erdogan - who said he narrowly missed being assassinated by the mutineers - is using the revolt as a pretext to extend and consolidate his power.

The failed coup, they say, has armed Erdogan with ammunition to remove remaining obstacles to his drive to replace Turkey's parliamentary democracy with a presidential system, a move that would require changing the constitution and which his opponents see as a path to growing authoritarianism.

"He can become the president he has dreamt of, but the country is unmanageable right now," said one government critic who declined to be identified for fear of arrest.

"There are no functioning laws to take the heat out. This is a closed system accumulating pressure all the time ... We have entered an abyss."

Erdogan's aides dismiss such claims. His spokesman, Ibrahim Kalin, said it took several thousands soldiers to carry out the coup attempt and that it was "only natural" for Turkey to apply the rule of law to arrest suspects on charges of treason.

"There's nothing exceptional or surprising about the fact that several thousand people have been arrested," he told reporters in Istanbul.

Erdogan called the coup "a gift from God" enabling him to "cleanse the army", and the massive purges have included the constitutional court, seen by Erdogan's critics as the sole body still able to challenge an erosion of the rule of law.

"This coup changes everything. The country is in a very tense mood. The ferociousness of the crackdown is a big worry," said Mustafa Akyol, a columnist and author of "Islam without extremes: a Muslim case for Liberty".

"There is a major upheaval in the army and the security forces and a lot of officers will be purged. How they will replace them (and) how they will train them are major issues," he said. "It is a major, major crisis."


On Turkey's streets, emboldened Islamist followers of Erdogan's Justice and Development Party (AKP) have paraded in a show of support, fuelling fears of retribution against those seen as pro-Gulenist or other opponents. Some public figures critical of Erdogan are keeping a low profile.

"How you demobilize the crowd is a concern. I don’t think it is high up on the list of concerns of the AKP government because they really feared for their lives," Altinay said.

A senior Western diplomat based in Ankara said the public mood and the mobilization of "Islamist mobs" was worrying, as was what appeared to be the mass screening of civil servants.

"Erdogan has gotten so much power and prestige now and being critical of him at this stage is not possible, you will be accused of being with the coup...The upheaval will be there for a while," Akyol said.

The failed coup has exposed the fragility of the military and intelligence services, which failed to detect early on an extensive plot involving senior commanders from the army and air force.

"This is so surreal. There is institutional collapse on many levels. The top two generals were taken hostage by their two closest aides," Altinay said.

"I'm sure their confidence is shaken because if they can't even choose the people with whom they are going to spend 24 hours, how are they going to trust anyone else. It is such a blow," he said.

The latest events leave Turkey, already reeling from the effects of attacks by Kurdish and Islamic State suicide bombers, more exposed and vulnerable.

Despite the rallying of the main opposition parties behind Erdogan as the army mutiny unfolded, there are fears among secularists that the country, already divided over the AKP's increasingly emphatic Islamism, will drift further towards more populist religious politics and a tighter autocratic structure.

Observers point to the unprecedented call by imams at mosques across the country, answering Erdogan's appeal and urging believers to take to the streets to defend their country.

"Turkey's democracy and western affiliation may end up being the coup's first victims," said Marc Pierini, former EU ambassador to Ankara and a visiting scholar at Carnegie Europe.

(Created by Samia Nakhoul; Editing by Nick Tattersall, Janet McBride)