ISTANBUL, Jan 6 - Not long before he retired as Turkey's military chief, General Ilker Basbug warned prosecutors: Take your hands off the armed forces.
Now he is locked up in jail, pending possible trial, accused of plotting to oust Prime Minister Tayyip Erdogan's government.
It was a stunning fall from grace for a man who once commanded the second-largest army in NATO.
But shocking though it is, Turks have become used to seeing generals, retired and serving, paraded before the courts on charges related to conspiracies against Erdogan's AK Party, which is led by former Islamists who have a long history of tension with the secular military.
Basburg, now 68, graduated as an infantry officer from Turkey's Army Staff College in 1961 and went on attend Britain's Sandhurst military academy and the NATO Defense College.
In a career that spanned five decades, he served in the commandos and an armoured division and was twice attached to the NATO supreme headquarters in Mons, Belgium.
Regarded by contemporaries as the most cerebral officer of his generation, the classical music-loving Basbug was said to rarely lose his temper.
But during his time as armed forces chief, he appeared increasingly frazzled as conspiracy accusations flew thick and fast.
I say openly as the chief of general staff: take your hands off the TSK (Turkish Armed Forces), he told a news conference in 2009.
Leaving the Istanbul court late Thursday, Basbug called the case against him tragi-comic and called on the Turkish people to judge him.
Respect for the military is strong among Turks, who are proud of the soldier-statesman Mustafa Kemal Ataturk who founded the republic out of the ashes of the Ottoman Empire in 1923.
But there is also an overriding desire to leave behind the era of coups that wrecked Turkish democracy in the late 20th Century and bring closure on a dark chapter stained by extra-judicial killings and torture, and a three-decade-old Kurdish insurgency that has cost over 40,000 lives.
The case against Basbug is focused on allegations that the military set up websites to run black propaganda to destabilise the government and it alleges links to a shadowy ultra-nationalist network dubbed Ergenekon.
Defending the military against such accusations became a feature of Basbug's tenure from 2008-2010, and he complained of asymmetrical psychological operations against the military being run through a pro-government media.
In the early hours of Friday morning, Basbug was taken to Silivri prison outside Istanbul, where some 200 officers have languished since late last year.
Those officers, including retired First Army commander Cetin Dogan, are caught up in the alleged Sledgehammer plot that harks back to 2003 and supposedly involved plans to bomb mosques in Istanbul and create a near-war situation with Greece in order to destabilised the AK government.
Dogan's son-in-law, Harvard University professor Dani Rodrik, says the accusations against Basbug are preposterous.
The charge that General Basbug is a member of a secret terror organization is beyond ludicrous, Rodrik told Reuters.
This seems to be just the latest in an escalating set of efforts by Turkey's fanatical special courts to chill the military leadership -- present and future -- into submission.
Basbug's lawyer is appealing against the court order that he be remanded in custody.
Appointed in 2008, Basbug took over at a time when Erdogan had already asserted civilian supremacy over the military using reforms meant to strengthen democracy and make Turkey a more suitable candidate for European Union membership.
He succeeded a more impetuous and confrontational chief of staff in General Yasar Buyukanit, whose tenure coincided with the so-called e-coup -- another memo posted on a website meant to derail the election of AK Party loyalist Abdullah Gul in 2007 because his wife wore a Muslim headscarf -- that exposed the military as a paper tiger politically.
Given the turn in the tide against the military, Basbug is believed to have been reluctant to take on the role of chief of staff.
His time as chief was marked by recurring tensions with the government, and the mounting detentions and accusations against officers took their toll.
Since then, Erdogan has driven the military out of politics, made officers in criminal cases answerable to civilian courts instead of military ones, and allowed the prosecution of generals who led coups in the past.
Turkey's military ousted four governments between 1960 and 1997 but most Turks believe the age of military takeovers is long gone, and as chief Basbug repeatedly assured them there were no would-be coupmakers left in the military.
While Basbug's detention will undoubtedly stir emotions, it is unlikely to generate a backlash in the military beyond possible protest resignations.
Erdogan won a third term in office last June in an election where the AK Party took 50 percent of the vote, and there is little political threat from a moribund opposition.
For NATO allies, the ongoing turmoil in civil-military relations in Turkey comes at a bad time, with the U.S. pullout from Iraq, the West's tensions with Iran and the chaos and revolt in Syria. Muslim Turkey borders all three countries.
(Writing by Simon Cameron-Moore)