ISTANBUL (Reuters) - Just weeks ago, Commander Adem Huduti was inspecting Turkish troops on the Syrian border and being praised in the media for his role in the fight against Islamic State and Kurdish militants.
Now, the head of Turkey's second army, responsible for its borders with Syria and Iraq, is in prison in Duzce, some 216 km (134 miles) east of Istanbul, the most senior serving general arrested for suspected involvement in a failed military coup.
At least 246 people were killed and more than 2,000 injured on the night of July 15, when a faction within the army used fighter jets, helicopters and tanks to try to seize airports and bridges, attacking buildings including parliament and the intelligence headquarters in a bid to seize power.
The plot crumbled quickly. But it exposed and exacerbated divisions within the second largest military in the NATO alliance, raising questions about its ability to contain a growing threat from Islamic State in neighboring Syria and a renewed insurgency by Kurdish militants.
"The Turkish military is now a broken force and it will take years for it to heal," said Aaron Stein, resident fellow at the Washington-based Atlantic Council, whose research focuses on Turkey and regional security.
"The plot extends beyond a rogue faction ... Beyond the loss of Huduti, the entire security apparatus now has another threat to focus on, in addition to Islamic State and the on-going insurgency in the southeast."
Huduti is one of around a third of Turkey's roughly 360 generals to have been detained since the abortive coup, more than 100 of them already charged pending trial. Authorities have also launched mass purges of state institutions, from the police and judiciary to academia and the civil service.
Huduti has denied being involved in the plot. In eight pages of testimony published by the Hurriyet newspaper, he said armed coup plotters tried to force him to join them but he refused, ordering his men to stay in their barracks.
Huduti was "an experienced commander in border security and regions of crisis", the Haberturk newspaper said last December. The pro-government Sabah daily in March hailed him as "the commander who has cleansed Cizre and Sur," two southeastern areas that saw the heaviest clashes with Kurdish militants.
Guilty or not, the coup plot and the detention of thousands of soldiers have shaken the armed forces in a country where the military long saw itself as the ultimate guardian of secular democracy, and where there had not been a violent military coup for more than 30 years.
"What we have seen in the last few days is the start of a process which will have an impact on Turkey and its armed forces for the next 20-30 years. It is monumental," said Gareth Jenkins, an Istanbul-based writer on Turkey's military.
"We will see a very highly politicized military now, just as the civil service has become. Dismissals and detentions have a knock-on effect on the whole chain of command ... The inevitable loss of trust has a big impact on operational capabilities."
Former NATO Supreme Commander James Stravridis said the fallout from the coup attempt would have a “chilling effect” on Turkey’s military readiness.
"There will be a strong negative impact on the ability of the Turkish military to perform its duties across the spectrum of alliance activities," he wrote in the latest issue of Foreign Policy magazine.
"Unfortunately, it is likely that the military in the wake of the coup will be laser-focused on internal controversy, endless investigations, and loyalty checks — and simply surviving as an institution."
In an interview with Reuters on Thursday, President Tayyip Erdogan acknowledged there had been intelligence failures and said the armed forces would now have to be restructured quickly to bring in "fresh blood".
The Supreme Military Council (YAS), the highest body responsible for appointments in the armed forces, will meet under Erdogan's supervision on July 28. There are likely to be significant personnel changes.
Akin Ozturk, head of the air force until 2015 and a member of YAS, was one of the masterminds of the plot, Turkish officials have said. Erdogan's aide-de-camp is also among those to have been detained.
At least a quarter of the generals who have been formally arrested are from the air force, a part of the military crucial not only in the fight against Kurdistan Workers Party (PKK) militants in Turkey's southeast, but also in the U.S.-led coalition against Islamic State.
Erdogan has blamed the coup plot on U.S.-based Muslim cleric Fethullah Gulen, an ally-turned-foe whose network of millions of followers have built influence over decades in the military, police, judiciary and parts of the state bureaucracy.
Erdogan's critics say he and the Islamist-rooted AK Party he founded allowed Gulen's followers to rise to key positions within the state apparatus to help curb the power of the military, which had ousted four governments since 1960 for posing what it saw as an Islamist threat to the secular order.
Critics say it was mainly Gulenist prosecutors who, around the time in 2008 when Erdogan's AK Party narrowly escaped being banned, built two big conspiracy trials targeting the upper echelons of the army. Hundreds of officers were jailed.
It later became clear, after many charges were dismissed, that bogus evidence had been used in the two cases, known as "Ergenekon" and "Sledgehammer". Those jailed were released, but several former senior officers said the cases weakened the armed forces and helped the Gulenists to rise through the ranks.
"We knew there was a Gulenist structure within the army, I knew some of them by name. But now I realize the situation was more grave than I thought," said Ahmet Yavuz, 61, a retired major general who was jailed in the Sledgehammer trial.
"The government and those who ran the armed forces ignored our warnings. They ruined the genetic makeup of the army and this created a space for the Gulenists to move within the army as they pleased," he told Reuters.
Gulen, now 75 and living in the U.S. state of Pennsylvania since 1999, denies any involvement in the failed coup. Turkey wants him extradited but the United States says it must first provide firm evidence of criminal wrongdoing.
Echoing Yavuz's comments, Mehmet Ali Celebi, a former army lieutenant also jailed over the Sledgehammer case, said many officers were angry that their warnings about the Gulenists' deepening grip in the military had been ignored.
"Nobody listened to us. It is now clear that those who accused us (in the Sledgehammer and Ergenekon trials) of plotting coups were the real plotters," he said.
The shake-up in the security apparatus is likely to see an increased role for police special forces, who have already taken on a more significant presence in and around Erdogan's presidential palace in Ankara.
The military presidential guard will be abolished, while the gendarmerie and coast guard will fully come under the authority of the Interior Ministry, Prime Minister Binali Yildirim said.
Turkey has suffered bomb attacks this year, including in Ankara and its biggest city Istanbul, some blamed on Islamic State, others claimed by Kurdish militants.
A triple suicide bombing and gun attack blamed on Islamic State killed 45 people and wounded more than 200 last month at Istanbul's main international airport.
"Turkey faces remarkable security concerns: the conflict with the PKK, Islamic State and other jihadis and now the danger of remnants from the coup itself," said Howard Eissenstat, a Turkey expert at St. Lawrence University in New York.
"The government really has no choice but to engage in broad purges of the military: it can't afford the possibility of "dead enders" remaining within its ranks. Rebuilding these forces will take a few years, but rebuilding the structures and trust will take even longer," he said.
Two senior Turkish officials said that while the priority was to cleanse the whole security apparatus of coup plotters, there was no risk to national security and that replacements were already being put in place for those detained.
But a third official was more cautious.
"The police headquarters is missing its front and back sides," he said, referring to one of the buildings bombed by the coup plotters during the events of July 15.
"There is not even a stable building. Will there be a security problem under these conditions...? You tell me."
Additional reporting by Orhan Coskun in Ankara, Robin Emmott in Brussels; Editing by Nick Tattersall, Janet McBride