Istanbul: At the crossroads between a divided Europe and a convulsed Middle East, Turkey is caught in a power struggle between former Islamist allies which is shaking democratic institutions and raises questions about its future path.

Turkish President Recep Tayyip Erdogan. AFP

Since a failed coup on 15 July, the ruling Justice and Development Party (AKP) founded by President Tayyip Erdogan has gained the upper hand in its battle with clandestine networks in the military, judiciary and bureaucracy loyal to US-based cleric Fethullah Gulen.

This fight to the bitter end has alarmed the West and unsettled the country of 80 million, which borders the chaos in Iraq and Syria and is a Western ally against Islamic State.

Erdogan accuses Gulen of masterminding the attempted coup by a faction within the military and has rounded up more than 60,000 people in an operation which he hopes will cleanse Turkey of what he calls the Gulenist "virus".

The purges, carried out as Turkey faces attacks by Islamic State and a revived struggle with Kurdish militants, go beyond the more than 100 generals and 6,000 soldiers held, or the nearly 3,000 judges detained.

They already encompass 21,000 teachers and much of the academic community, and new targets in a media already hit by years of firings and fines, jailings and closures.

"They are traitors," Erdogan told Reuters in an interview on Thursday. He described Gulen's network as "like a cancer" and said he would treat them like a "separatist terrorist organisation" and root them out, wherever they may be.

Gulen, 75, denies plotting against the state and suggested the day after the abortive coup that it may have been staged to justify a crackdown on his followers.

The millions of members of Gulen's "Hizmet" (Service) movement do not outwardly identify as supporters. Since the failed coup many are going even further underground, refusing to take calls or trying to leave the country.

Some followers are dumping books in the woods and publishers are getting rid of their stocks, said Nedim Sener, an investigative journalist at Posta newspaper who wrote a book on the Gulen movement’s efforts to infiltrate the state and was jailed in 2011 for more than a year.

A senior journalist at a Gulen-affiliated newspaper, speaking on condition of anonymity because he feared reprisals, said he and other editors were afraid to go to the paper's office in the days following the failed coup and that their printers refused to continue publishing.

"I advised my colleagues not to go to the office for their own safety," he said. "The newspaper has become a liability, it has just disappeared ... I'm afraid for my family and for my life. It's dangerous to go outside."

Asked if he was a follower of Gulen’s teachings, he said: "Answering this question could now be used as evidence against me. Now I could be prosecuted for a book I keep at home ... Everyone is too afraid to call their friends, worried this will cause their detention. It’s a climate of fear everywhere."

ALLIES TURNED FOES

Erdogan was prime minister from 2003 until 2014, when he became president. When he first came to power, he led a reinvented Muslim conservative party wary of fiercely secularist generals and judges who had closed a series of Islamist parties.

In the skirmishing that followed, and after the army and the courts tried to push aside the AKP in 2007-08, Erdogan turned for help to Gulen, whose movement had built a loyal following among police, prosecutors and civil servants.

Gulen, a Muslim imam self-exiled in Pennsylvania since 1999, has built a franchise of schools in Turkey and around the world, promoting the importance of education, scientific progress, religious coexistence and fighting poverty.

After their ascent to power, Erdogan and the AKP became dependent on the Gulenists in their common fight against the army. It was mainly Gulenist prosecutors who, after Erdogan and his party narrowly escaped being banned in 2008, built two big conspiracy trials targeting the upper echelons of the army.

These two cases, known as Ergenekon and Sledgehammer, netted more than 40 generals, but also swept up opponents of both the ruling party and the Gulenists. It later became clear after many charges were dismissed that bogus evidence had been used.

Yet at the time, the Gulenists’ apparent success in helping Erdogan break the army’s grip on Turkish politics emboldened them to demand more power in the security services and the army.

"It is essentially not a struggle about ideology because their ideology is so similar. Both want to turn Turkey into a more conservative Islamised society," said one Turkey analyst who asked not to be named after the declaration of emergency laws which could hit those critical of the state.

"It is a struggle about power and that alliance broke down because of disagreement over power-sharing."

PURSUIT OF POWER

If Gulenist penetration of state institutions is as deep as the purges suggest, then much of it must have happened while Erdogan was in charge.

"We never considered even the possibility that they might be involved in this kind of a treason. They were citizens of our country and we supported them to the fullest as citizens of our country," Erdogan told Reuters.

Sener said there had been a tendency to see Gulen as a religious leader, but he has always rejected this.

"He is a man who is in pursuit of power and power alone. Fethullah Gulen and his followers want to take over the organs of the state," he said.

"Had (Erdogan) taken this seriously he would have cleaned this up years ago. But he never imagined the guns would be turned on him."

The struggle between the former allies started in late 2011.

Erdogan had been re-elected that summer for a third term as prime minister, making no secret of his presidential ambitions. His posters emphasised power until 2023, the centenary of Mustafa Kemal Ataturk’s founding of the modern republic.

But when he suddenly had to pull back from the political fray and undergo surgery, prosecutors assumed to be loyal to Gulen targeted Hakan Fidan, Erdogan’s intelligence chief.

This apparent attempt to push Gulenist influence into the security services was like targeting Erdogan himself, who complained of betrayal, asking publicly: "What is it that we didn’t give you that you wanted?"

Tit-for-tat battles followed, electrifying Turkish politics. The government closed down the dershane, a network of private tutoring centres, mostly run by the movement. Gulenist prosecutors in 2013 launched corruption investigations into Erdogan’s cabinet and family. The gloves came off.

END OF THE MOVEMENT?

This degree of state infiltration, and the damaging leaks by prosecutors, revealed a power structure Erdogan loyalists described as a "parallel state" intent on taking power.

"It has aspirations to capture the state. They certainly came quite a long way in reaching this objective, they have certainly been helped and assisted by the AKP," said Sinan Ulgen, head of the liberal EDAM think tank in Istanbul and a fellow at the Carnegie Europe think tank.

"When AKP came to power they established an alliance. It helped to populate the Turkish administration with Gulenists."

Government officials say the Gulenists have carefully planned to seize state institutions for over three decades by using their schools and universities to prepare civil servants, something the AKP found difficult to match when it took power.

Gulen schools have identified and groomed generations of capable students, starting from primary schools through university and into their professional life. Many rose to influential jobs in the state and business.

"This is the more benign face of the movement but there is a dark face," Ulgen said, adding that it has steadily become more powerful over the past decade and succeeded in penetrating bodies such as the police, judiciary and prosecution service.

Sener said government hotlines set up for people to inform on suspected Gulenists meant the movement looked set for a fall.

"This movement will end," said Sener. "There are a few who are still hidden... To a very large extent, this is the end of the Gulen movement in Turkey."