Without a strong army, the Turkish republic would not exist. At the end of the First World War, the victorious allies were planning to carve up the territory among themselves, with Russia taking the east and Istanbul, and the French and the Italians taking the south, leaving only a rump Turkish state.
These plans were scotched by an officer named Mustafa Kemal who, in 1919, patched together an army and drove the colonial powers away. He is known to history as Ataturk, the founder of the republic.
The role of the Turkish army is unique in the region, and not just because of the prestige it gained in 1919-22. It has been the backbone of the state, as a unifying force for the various ethnic communities and the protector of Ataturk’s legacy of militant secularism.
Against this backdrop, the purge of the top ranks of the army undertaken by president Recep Tayyip Erdogan after last month’s failed coup is not merely a corrective to root out the conspirators, it threatens one of the pillars of the state.
In a decree on July 27, almost half of the country’s generals and admirals were discharged. Not all of them are accused of being followers of the exiled preacher Fethullah Gulen, whom the government blames for inspiring the mutiny.
Some may be suspected of other forms of disloyalty, or for displaying a lack of zeal in combating the coup plotters. Still, a root and branch reorganisation is under way, including closing the military colleges in which future officers were trained as a caste apart from society.
Not surprisingly, the army is demoralised at a time when it is fighting an insurrection by the militant wing of the Kurdistan Workers Party in southeastern Turkey, a bombing campaign by ISIL and a potentially catastrophic setback for the Turkish-backed rebels in Syria if Aleppo falls to the Russian-backed government forces. All this has caused anxiety to Turkey’s allies in the West, where the Nato alliance has long relied on Turkey’s 500,000-strong armed forces as reserve capacity.
Mr Erdogan’s Islamising policy and his growing suspicion of the United States have cast doubt on Turkey as an ally, but these fissures are almost certain to grow as the army is remade.
The mass dismissal of senior officers has been compared to Stalin’s purge of Soviet armed forces in 1937-38, when 35,000 officers were arrested on trumped-up charges – severely weakening the military before the Nazi invasion in 1941.
To pursue the Soviet analogy, Mr Gulen, the exiled preacher who has lived in rural Pennsylvania since 1999, should be Leon Trotsky, Stalin’s former comrade whom he had assassinated with an ice pick in Mexico. But Mr Gulen is an unlikely Trotsky: he appears to the world as an Islamist thinker who exhorts his followers to devote themselves to education and public service rather than politics, and certainly not armed revolution.
There is one similarity. When Mr Erdogan came to power in 2002, he had few friends in the state bureaucracy, and so relied on the Gulenists to organise mass show trials of army officers to ensure that the military could never force him out of power. The fantastical evidence of military conspiracies at the so-called “Sledgehammer” trials in 2012 has been shown to be fake. But the removal of some of the top brass allowed for some Gulen followers to rise in the ranks.
Inevitably the two arms of the movement fell out, with the Gulenists exposing the corruption and cronyism under Mr Erdogan until he declared his former allies terrorists in May this year.
Evidence released by the authorities from interrogations of some of the accused coup plotters suggests that the Gulenists in the military operated under the deepest cover, not knowing the names of their colleagues. This may explain why the coup failed to mobilise forces with enough speed to neutralise Mr Erdogan.
Or there could be another explanation which is more worrying for Mr Erdogan: powerful currents in the military – such as officers who believed Mr Erdogan’s wilful policy in Syria had opened the way for the Kurds to regroup all along Turkey’s south frontier – were expected to be part of the Gulenist mutiny, but failed to join it.
There are still many unanswered questions. What is clear is that Mr Erdogan intends to place all the security forces firmly under civilian control with responsibility shared between the president, the minister of defence and the minister of interior. This will surely serve to weaken the army’s political role in the state, but may also make it less effective in the security sphere.
These changes are so big that Mr Erdogan has offered an olive branch to the opposition parties – previously under severe pressure – in the hope that he can create a sense of national unity behind the military reforms.
What remains to be seen is how the new military will look. The hunt for the Gulenists will continue. But the real issue is whether the army will become more Islamic, and thus aligned to Mr Erdogan’s Justice and Development Party, which would require rooting out the secular tradition inherited from Mustafa Kemal.
At the same time, the geopolitical orientation is likely to change. For decades the army has worked closely with the US military, but Mr Erdogan is openly critical of American policy in Syria. Turkish commentators suggest the army may become less western and more “Eurasian” in its orientation.
Given the failure of US policy in Iraq, Afghanistan and Syria, maybe this should be no surprise. Mr Erdogan is flying to St Petersburg on Tuesday to meet Russian president Vladimir Putin. This is a chance to open a new era in relations after Turkey shot down a Russian strike aircraft in November last year. The visit may reveal more of Mr Erdogan’s intentions.
Alan Philps is a commentator on global affairs
On Twitter: @aphilps