Turkish President Recep Tayyip Erdogan has declared a three-month state of emergency after last week's failed military coup. (Reuters)

The day after rogue soldiers failed to unseat the government, some of Turkey’s top judges called an emergency meeting.

The 22 justices — known as the High Council of Judges and Prosecutors — convened Saturday in the Turkish capital, Ankara, which was the scene of heavy clashes the night before.

The council usually appoints judges and prosecutors and rules on cases of misconduct, which are then subject to review. But this time, the justices turned against their own and sacked nearly 3,000 judges, marking the start of a now-widespread government purge.

Stacked with supporters of President Recep Tayyip Erdogan, the council even suspended five fellow members.

The targeting of Turkey’s judiciary offers a window into how swiftly Erdogan’s allies on the council moved to eliminate opponents, eroding the rule of law and politicizing a system that relies on a balanced administration of justice. With such sweeping dismissals in the wake of the attempted coup, that impartiality is now under threat.

After a meeting with his National Security Council, Turkish President Recep Tayyip Erdogan is set to announce emergency measures to try to shore up stability and prevent damage to the economy. (Reuters)

Authorities have suspended or detained tens of thousands of bureaucrats for alleged links to the plot. Mass dismissals have also hollowed out the army, police, schools, universities and the state’s highest religious-affairs council, bringing the number of people in detention or newly unemployed to roughly 50,000.

About 800 judges and prosecutors have been taken into custody in at least 40 of Turkey’s 81 provinces, including two members of the Constitutional Court. An additional 262 military prosecutors have also been suspended. These dismissals represent nearly a fifth of all judicial officials, according to figures from the Turkish Justice Ministry.

“It’s total chaos. They are not applying any kind of law at this stage,” Gunal Kursun, assistant law professor at Turkey’s Cukurova University, said of the legal system.

Rights advocates have warned that the speed with which the government is firing and detaining opponents suggests authorities have bypassed laws requiring criminal investigations.

“The courts are only a formality at the moment,” Kursun said. Right now, “they are not really working as courts.”

On Thursday, researchers for Amnesty International and Human Rights Watch said that a prominent human rights lawyer, Orhan Kemal Cengiz, had been detained at Istanbul Ataturk Airport. He was taken into custody with his wife, writer Sibel Hurtas, and transferred to a police station in Istanbul.

What we know about the failed coup attempt in Turkey

The Turkish government did not immediately respond to a request for comment on Cengiz’s reported detention.

“Very concerned to hear from [Cengiz and Hurtas] they are detained at Ataturk airport,” Human Rights Watch’s Turkey director, Emma Sinclair-Webb, posted on Twitter.

Gutting the judiciary in the aftermath of a coup seems counterintuitive, legal experts say. The government ostensibly needs the legitimacy of the law to arrest and prosecute conspirators and would not want anything to jeopardize those convictions. Also worrying is the fact that the judiciary played no overt role in the bid to oust the government Friday night.

It was a mutinous faction of the military that hijacked aircraft, gunned down civilians and declared martial law by taking over state broadcasters. But having just survived a violent coup, authorities here are in no mood to tolerate dissent.

According to the president and other officials, followers of a Muslim cleric and Erdogan rival, Fethullah Gulen, were responsible for the conspiracy. For years, Erdogan and his supporters have accused “Gulenists “of infiltrating state institutions — including the judiciary — in an attempt to create a “parallel state.”

Gulen and Erdogan — both religious Muslims — were once allies against holdouts of Turkey’s staunchly secular and militaristic republic, founded by nationalist Mustafa Kemal Ataturk in 1923.

But when allegedly pro-Gulen prosecutors launched corruption probes into Erdogan's senior ministers, the relationship quickly soured.

Turkey's judiciary, then, emerged as one of the last institutions capable of challenging Erdogan, who had consolidated power as president with a comfortable majority in parliament.

But the feud also turned its judges into targets. Now, officials say, long-running investigations into the Gulen movement’s “penetration of law enforcement, the judiciary, and the military” have allowed authorities to move quickly to arrest the coup plotters.

One senior official, speaking on the condition of anonymity in line with government protocol, said the decisions to detain or suspend certain judges “are made based on financial transactions and communications between the individuals in question and the putschists.”

Gulen, who lives in self-imposed exile in Pennsylvania, has denied any role in the plot to bring down the government.

Historians and Turkish legal experts say the purge — both within the judiciary and more generally — is probably the biggest in Turkey’s modern history. The country has been through four successful military coups since its founding nearly a century ago.

Cengiz, the lawyer reported to be detained, said in an interview earlier this week that “during [the rule of] previous military juntas, there were similar purges, but never to this scale.”

While there has been no formal declaration, Cengiz said that in practice, “the constitution is suspended right now.”

Erdogan said in the aftermath of the attempted coup that “at every level of government, the period of cleaning this virus will continue.”

“Like the cancer virus, it spreads all around the government,” he said.