Following Turkey's failed military coup of 15 July, the government plans a complete restructuring of the country's armed forces and intelligence services with wide-ranging implications both for the immediate region and the strategic balance between NATO and Russia. Since the 18th century, Turkey's armed forces have led the twin quests for modernity and political stability in the country, helping to create a nationalistic, but pro-western, regional power vastly stronger and more prosperous than the late Ottoman Empire. Now all that could be about to change. Turkish president Recep Tayyip Erdogan wants a sweeping overhaul of the military following last month's abortive coup, during which the country's parliament was bombed and at least 260 people killed. There is also the subsequent discovery – there seems to be no reasonable doubt about it – of a massive plot inside the army led by followers of the exiled Sufi cleric Fethullah Gulen, although the latter has denied any involvement. This is understandable. The conspiracy was so extensive that even Erdogan's own aide-de-camp, Ali Yazici, and the commander of the presidential palace guards are alleged to have taken part. Even before recent events, the Islamist Justice and Development Party (AKP), which has ruled Turkey since 2002, wanted the power of the army curbed. As a result of earlier coups, the country's military functioned until recently as an autonomous corporation inside the state, with no effective civilian control over it as it defended the country's secular legal and political institutions against rising Islamist power. To observers outside Turkey as well as within the country, this praetorian shadow guard looked anachronistic and unnecessary. Though it never seems to have made it public, the EU set up a committee during the early 2000s to examine the role of the Turkish military in the country's politics, according to an EU source in Turkey. The committee concluded that this role must end for Turkey to become an EU member. The military, however, acquiesced in the rise to power of the AKP and, thanks to senior commanders, the predicted coup at that time never happened. The failure was in part because since about 1990 all shades of Turkish civilian opinion have been resolutely determined to resist any coup, a problem that the 15 July conspirators believed they could overcome by shooting live bullets at the crowds. From 2008 onwards, the power of the old secularists in the military was broken by arrests, trials and the imprisonment of about 300 officers, including 72 generals. It was organised by pro-Gulen prosecutors and judges using fake evidence, as was subsequently established in court. In the aftermath of the coup attempt, some of these formerly imprisoned officers have now been reinstated in senior positions. What few people outside the military had any inkling of was how the military had been systematically infiltrated since 1986 by followers of Gulen. The government alleges that the majority of military cadets taken into armed forces schools since 2000 were Gulenists who had been given entrance the exam papers in advance, allegations which parallel similar charges against the Gulenists in the university entrance system. The elaborate ways in which they concealed themselves and their loyalty to Gulen included drinking alcohol as a way of allaying suspicion and hiding their distinctive prayers and other observances so as not to draw attention to their affiliation. Still, it is difficult not to feel that there was a serious oversight by both the government and senior officers, since many Gulenists seem to have been easily identifiable to their brother officers. IMPLICATIONS FOR THE WEST: Turkey's armed forces now stand at a crossroads, with the Gulenist officers and their friends gone and 119 generals and admirals now being held, exactly a third of the total number, and nearly half removed from their pre-coup positions. A further 3,000 soldiers have been purged. The foremost priority is to prevent another coup attempt, but a second and more long-standing goal is to replace the pro-NATO and western character of the armed forces with a more Islamist one, in line perhaps with Turkey's aspirations for closer military cooperation with other Sunni Muslim countries, especially Saudi Arabia. This was blocked until recently not only by restrictions on taking graduates from certain schools, but also by the western-style military culture inculcated by military schools and academies set up in late Ottoman times. The cadets at these schools have been discharged and there is talk (not yet confirmed) that the historic military schools are to be replaced with entry to the officer corps via the standard civil service exams. The bigger underlying question is the future of Turkish military links with NATO. Reliance on NATO may be reduced but is unlikely to end. Doing so would mean writing new training manuals and ending innumerable standard military procedures and procurement processes, something which would risk weakening the capacity of an army which is currently confronted by the Kurdistan Workers Party (PKK) and the Islamic State (IS) group and has to be vigilant elsewhere. It would also remove Turkey's ability to call for support from its NATO allies if attacked: this is something that a country living in a dangerous neighbourhood values. But western legislators could yet upset this picture if they engage in clumsy anti-Turkish moves comparable to the arms embargo introduced in the 1970s by the US Congress. This introduced the first large crack in the Turkish-Western strategic relationship and resulted in Ankara expanding its domestic military electronics, munitions and aviation industries. We are likely to see, then, the emergence of what are essentially new Turkish armed forces, answerable directly to Erdogan and the presidency and with a definite Islamist character. Such a change would not necessarily weaken the country's military capacity for very long: with armed forces of around 620,000, Turkey can utilise the skills, resources and technology of its existing armed forces in building their replacement. The challenge it faces in doing so would be considerably less than that of Iran when it had to reconstruct a new military in the 1980s after the collapse of the former shah's regime. And Tehran still went on to achieve at least stalemate in the Iran-Iraq War and become an effective regional military force. Turkey can utilise the skills, resources and technology of its existing armed forces in building its replacement. Though Turkey currently seems inclined to scale down its international military involvements and is apparently seeking terms with Russia over Syria, and presumably also Syrian president Bashar al-Assad, that phase might not last for long once a new army is fully operational, particularly if moves to establish a Kurdish state in Syria continue. Historical precedents suggest that new armies formed after revolutions with new generals tend to be strong and assertive. Viewed against this background, recent American attempts to soothe Turkish anger about the role of the US-based Gulen in the 15 July coup attempt, such as the recent visit to Ankara of US general Joseph Dunford and that of US secretary of state John Kerry on 24 August, may be insufficient to win back an ally that the US never expected to lose. The writer has worked in Turkey as a journalist and university teacher and writes regularly on Turkish politics and history.