Western allies have warned Turkish President Recep Tayyip Erdogan must maintain a measured response to the quashed coup attempt as concerns grow that his purge of the military will destabilize the fight against Islamic State within and alongside the country's borders.

Up to 20,000 state officials including police officers, military personnel and judges have been suspended or arrested since the failed coup. The president has said he is considering the death penalty "if people demand it" against some of the alleged coup plotters.

On Monday (18 July), one of the alleged ringleaders, General Akin Ozturk, appeared in court bruised and injured, and denied any involvement in the uprising in which 232 people were killed and 1,400 wounded.

But associate fellow of Chatham House's Europe programme, Fadi Hakura, told IBTimes UK that the loss of key military figures could play into the hands of IS (Isis/Daesh) and other terrorists.

This is a concern given that Turkey has witnessed 14 major bomb attacks over the past year carried out by IS or the Kurdish separatists, the PKK.

He said: "At a time where the major security and intelligence institutions are now convulsed in an extensive 'cleansing' operation, the question is: who will replace the tens of thousands of officials in security, defence and intelligence?

"This major rejigging will likely have a knock-on effect on the cohesion and capacity of the military, the police and security and intelligence services. Some of the military that have been detained are generals who have experience of patrolling the Syria and Iraqi border for decades.

Recep Tayyip Erdogan
Turkish President Recep Tayyip Erdogan waves to the crowd following a funeral service for a victim of the thwarted coup in IstanbulAlkis Konstantinidis/ Reuters

"Usually that experience is transferred to younger officers. Now that experience is completely gone and that institutional memory has disappeared. That leaves a major gap in the workings and the functioning of the military intelligence and police," he said.

Also among those suspended are a number of Erdogan's allies, including 30 out of the 81 provincial governors, who were all appointed by the president. The UN High Commissioner for Human Rights, Zeid Ra'ad Al Hussein, voiced "serious alarm" at the mass suspension of judges and prosecutors.

He said, according to Reuters: "In the aftermath of such a traumatic experience, it is particularly crucial to ensure that human rights are not squandered in the name of security and in the rush to punish those perceived to be responsible."

Turkey coup Recep Tayyip Erdogan
Supporters of President Erdogan hold an effigy of US-based cleric Fethullah Gulen hanged by a noose, in a pro-government demonstration in Istanbul's Taksim SquareAlkis Konstantinidis/Reuters

Kristin Hausler, from the British Institute of International and Comparative Law, who has carried out an in-depth study of Turkey's judicial system, told IBTimes UK that she feared that the attempted coup could lead to changes in legislation and that Erdogan's statement that he may reinstate the death penalty was a big concern and would be "a big step backward".

"Over the last decades there were changes in legislation that followed such military intervention so I believe that there is a risk to further amendments to existing legislation following the attempted coup which may curtail human rights and the rule of law even further," she said.

The Turkish government have demanded the US extradites the Pennsylvania-based Fethullah Gulen whom it accuses of orchestrating the attempted takeover. Prime Minister Binali Yildirim said that the US has been sent a dossier to Washington, which will only consider an extradition request if clear evidence is provided.

Meanwhile, thousands of people have demonstrated in squares in the country's three biggest cities to show their support for Erdogan.

However, the febrile atmosphere besetting Turkey was demonstrated after an unknown assailant shot and killed the deputy mayor of Istanbul's well-to-do Sisli district, Cemil Candas, although it is unclear if there was any connection with the attempted coup.

Turkey: Hundreds demonstrate to show support for President as more arrested after failed coupReuters