The problem is not limited to the judiciary. Turkey today is a far cry from the country the AKP promised 14 years ago, with the government backtracking or turning about on key matters shaping the course of the country.

The first harbinger of the current turmoil was perhaps the 2010 referendum on constitutional changes that profoundly reshaped the judiciary. Erdogan drummed up popular support for the amendments, arguing they would end the supremacy of elites and make the judiciary truly independent and impartial. Soon, however, Erdogan and his aides would admit that Gulenist judges and prosecutors took advantage of the amendments to take control of the judiciary. This admission, however, happened only after massive corruption probes targeted government ministers and Erdogan’s family in December 2013, shattering the decadelong alliance between the AKP and the Gulen community.

The toll of the July 15 coup attempt, blamed on followers of US-based cleric Fethullah Gulen, is staggering. Some 250 civilians were killed and around 1,500 injured. As of July 28, about 16,000 people were detained, including 9,000 in jail pending trial. Close to 50,000 public employees were dismissed, and 149 generals and admirals , roughly 40% of the total, were expelled from the military. Dozens of media outlets were shut down, and arrest warrants were issued for more than 50 journalists. The pre-charge detention period was extended from four to 30 days. The crackdown is being conducted through legislative decrees, made possible under the emergency rule declared after the coup attempt.

After 14 years of AKP rule, Turkey is in turmoil. The events that led to this state of affairs boil down to one simple reason: the AKP’s skewed understanding of democracy and popular will.

A July 27 cartoon by popular Turkish cartoonist Musa Kart speaks volumes. Ruminating after the failed coup attempt, President Recep Tayyip Erdogan is depicted wondering, “Somewhere I didn’t make a mistake, but where?” Indeed, the list of the Justice and Development Party’s (AKP) wrongs is so long that the rights are hardly discerned.

Take, for instance, emergency rule. The AKP had long boasted of ending a lengthy state of emergency in the Kurdish-majority southeast in the early 2000s, but today the whole country is under emergency rule, while dozens of cities and towns in the southeast lie in ruins after a ferocious crackdown on Kurdish militants. Similarly, the government used to boast of stamping out torture, but today Turkey is back on the watch list of leading rights groups. Even the restitution of the death penalty, removed from the books in 2004, is back on the agenda.

Keen to end the military’s tutelage in politics, the AKP backed sprawling trials of army officers accused of plotting to topple the government, which extended also to dissident journalists and intellectuals. The so-called Ergenekon and Sledgehammer cases led to a big purge in NATO’s second-largest standing army and upended its line of succession, which, as it turns out now, cleared the way for the ascent of the Gulenist officers accused of leading the July 15 coup attempt. Ironically, some of the officers who spent years behind bars in the sham trials were instrumental in foiling the coup, and some have been reinstated to senior positions. After the Gulenist-AKP alliance collapsed, the government grumbled how Gulenists in the police and judiciary had “framed” the military and designated the Gulen community as the “Fethullahist terrorist organization” (FETO). The coup attempt was only the culmination of the open war that had raged between the two since then.

On another front, the Gulen community had long been accused of stealing the questions of public service exams to install its followers in state offices. Erdogan had defended the exams as “clean” despite ample indications to the contrary. Now, the AKP chorus says “FETO was able to infiltrate the state by stealing the exam questions.”

Throughout the years, the AKP was persistently cautioned by opposition parties and the media. But criticism of the Gulenists was flatly dismissed, often perceived as malicious secularist attacks on devout Muslims. AKP leaders and supporters lauded the Gulenists as an exemplary charity movement, paid visits to Gulen in Pennsylvania and praised the community’s schools, which are now being closed en masse. But not only that. The AKP saw the critics as enemies, vilified them and often portrayed them as “bootlickers” of the military. Erdogan and the AKP, after all, knew best how to run the country. Riding on a high horse, Erdogan disparaged opposition parties as “incapable of even herding a few sheep” and told critics “to keep their wisdom to themselves.”

The result is a Turkey stuck in a miserable governance crisis — the product of a mindset that sees democracy as dictating one’s own will on others and rejects any compromise with opposing thinking. Lending an ear to the opposition would have probably prevented much of the current disaster. The AKP’s own backpedaling and turnabouts are arguably a proof in itself that the opposition was right on many issues of governance, not to mention foreign policy and the Syrian crisis.

The price for Turkey is steep. Veering off from its European Union membership path, it is back to ground zero as a country associated with military coups, emergency rule, torture and mass detentions. The question now is whether the AKP can face up to its mistakes and move to control the damage.

Some positive signs have emerged to that effect. Erdogan this week convened a rare meeting with Prime Minister Binali Yildirim and the leaders of the opposition Republican People’s Party (CHP) and Nationalist Movement Party (MHP), which resulted in a deal for a constitutional amendment on judicial independence. The downside was the exclusion of the pro-Kurdish Peoples’ Democratic Party. In a further gesture, Erdogan retracted libel cases against the MHP and CHP leaders.

If the AKP sticks to this course with an earnest sense of reconciliation, Turkey stands a chance to extract a silver lining from the bloody coup bid and salvage its democracy.

Yet, one should take the gestures with a big grain of salt, given the AKP’s 14-year record and the practices unfolding under emergency rule. This is true also for this writer, who was the first in the Turkish media to use the term “parallel setup” — as uttered by intelligence chief Hakan Fidan — to describe how mighty the Gulen community had become. This was back in 2012, a whole four years before the putschists shed blood.