By Roger Hardy
BBC Middle East analyst
The head of Turkey's military has insisted coups are a thing of the past
There has never been much love lost between the Turkish military and Prime Minister Recep Tayyip Erdogan's Justice and Development Party (AKP), which came to power in 2002.
The generals believe the AKP has a hidden agenda to subvert the country's secular system.
The AKP, for its part, sees the military as standing in the way of democratic reforms essential to Turkey's attempt to join the European Union.
But a string of allegations about coup plots by the military - and this week's arrest and formal indictment of seven senior military officers, including four admirals, a general and two colonels - have brought these tensions to a new level.
They raise fundamental questions about whether peaceful cohabitation is possible between the staunchly secular military and a governing party with Islamist roots.
And for Turkey's Western allies, they raise troubling questions about where the country could be heading.
Opinion polls routinely confirm that in a country where politicians are widely seen as corrupt and self-serving, the armed forces are Turkey's most trusted institution.
The army has overthrown elected governments three times since 1960
But for the role of the army after World War I - when under the leadership of the republic's founding father, Mustafa Kemal Ataturk, it won the independence struggle - modern Turkey would not exist.
Moreover, the generals and their allies in the bureaucracy, the judiciary and the media, see the armed forces as the ultimate guardian of Ataturk's legacy.
The army has intervened to overthrow elected governments three times since 1960 - four, if one includes the so-called "post-modern coup" of 1997, in which it forced from office the country's first Islamist prime minister.
HOW 'COUP PLOTS' EMERGED
June 2007: Cache of explosives discovered; ex-soldiers detained
July 2008: 20 arrested, including two ex-generals and a senior journalist, for "planning political disturbances and trying to organise a coup"
July 2008: Governing AK Party narrowly escapes court ban
October 2008: 86 go on trial charged with "Ergenekon" coup plot
July 2009: 56 in dock as second trial opens
Jan 2010: Taraf newspaper reports 2003 "sledgehammer" plot to provoke coup
Feb 2010: More than 40 officers arrested over "sledgehammer"; seven charged
But the election victory of Mr Erdogan and the AKP in 2002 presented the generals with a challenge of an altogether new kind.
For one thing, the AKP was able to govern alone, unlike the string of quarrelsome coalition governments that had preceded it.
For another, it won plaudits at home and abroad for a series of wide-ranging political and economic reforms designed to secure Turkish membership of the European Union.
Part of the reform process involved efforts to keep the military in their barracks - and out of politics.
If this gradual shift of power from the military to the civilians had taken place in a calmer atmosphere, the military might - just - have accepted their new role.
Instead, a series of crises have produced bitter recrimination and left relations between the government and the generals increasingly frayed.
Justice or vendetta?
Can further polarisation be avoided? Right now, the prospects seem dim.
The AKP and its supporters say the evidence of military-inspired plots to overthrow the government is overwhelming.
Dozens of members of the military have been arrested in recent years
The army and its allies retort that much of the evidence is flimsy or even fabricated and that what is under way is a politically motivated vendetta to discredit the country's leading patriotic institution.
Is either side prepared to blink?
If Mr Erdogan presses the issue even harder, this will strengthen the view of his critics that he is out to settle scores and is becoming increasingly authoritarian.
But, as they watch their power and credibility eroding, the generals find themselves in a bind.
To wage a war of attrition against the AKP, which has already won two convincing election victories, could simply ensure it wins a third.
There is no credible political rival on the horizon.
Besides, the current chief of the Turkish general staff, the widely respected Gen Ilker Basbug, says coups are a thing of the past.
Still clinging to its traditional role as guardian of the nation, but aware the tide of history is moving against it, the Turkish military finds itself at an uncomfortable crossroads.