Ever since Turkish President Recep Tayyip Erdogan won his first general election in late 2002, he’s been obsessed with the idea that power would be wrested from him through a coup. He had good reason to worry even then. Turkey’s ultra-secularist establishment, ensconced in the upper echelons of the judiciary and the military at the time, made no secret of its antipathy toward Erdogan and his political allies.

Erdogan himself had been jailed for reciting religion-laced poetry, which prevented him from taking office immediately when his Justice and Development Party (AKP) assumed office in November 2002. In 2007, the military issued a statement opposing the AKP’s candidate for president—then largely a figurehead. And in 2008, the party narrowly escaped being shut down by the country’s top court for ‘anti-secular activities’.

The old guard’s efforts largely backfired and served only to augment Erdogan’s popularity. His strengthening grip on power might have mollified him and led to a less confrontational political style. Instead, in the ensuing years, his then-allies the Gülenists—followers of the cleric-in-exile Fethullah Gülen—managed to whip Erdogan’s obsession into paranoia.

From 2008 to 2013, Gülenists in the police, judiciary, and media concocted a series offictitious conspiracies and plots against Erdogan, each more gory than the last. They ran sensational show trials targeting military officers, journalists, NGOs, professors, and Kurdish politicians. Erdogan may not have believed all of the charges—a military chief with whom he had worked closely was among those jailed—but the prosecutions served their purpose. They fed Erdogan’s fear of being toppled, and eliminated the remaining vestiges of the secularist regime from the military and civilian bureaucracy.

The Gülenists had another motive as well. They were able to place their own sympathisers in the senior ranks vacated by the military officers targeted by their sham trials. The Gülenists had spent decades infiltrating the military; but the commanding heights had remained out of reach. This was their opportunity. The ultimate irony of July’s failed coupis that it was engineered not by Turkey’s secularists, but by the Gülenist officers Erdogan had allowed to be promoted in their stead.

By the end of 2013, Erdogan’s alliance with the Gülenists had turned into open warfare. With the common enemy—the secularist old guard—defeated, there was little to hold the alliance together. Erdogan had begun closing Gülenist schools and businesses and purging them from the state bureaucracy. A major purge of the military was on the way, which apparently prompted Gülenist officers to move pre-emptively.

In any case, the coup attempt has fully validated Erdogan’s paranoia, which helps explain why the crackdown on Gülenists and other government opponents has been so ruthless and extensive. In addition to the discharge of nearly 4,000 officers, 85,000 public officials have been dismissed from their jobs since 15 July, and 17,000 have been jailed. Scores of journalists have been detained, including many with no links to the Gülen movement. Any semblance of the rule of law and due process has disappeared.

A great leader would‘ve responded differently. The failed putsch created a rare opportunity for national unity. All political parties, including the Kurdish People’s Democratic Party (HDP), condemned the coup attempt, as did the vast majority of ordinary people, regardless of their political orientation. Erdogan could have used the opportunity to rise beyond Islamist, liberal, secularist, and Kurdish identities to establish a new political consensus around democratic norms. He had a chance to become a democratic unifier.

Instead, he has chosen to deepen Turkey’s divisions and erode the rule of law even more. The dismissal and jailing of opponents has gone far beyond those who may have had a role in the putsch. Marxist academics, Kurdish journalists, and liberal commentators have been swept up alongside Gülenists. Erdogan continues to treat the HDP as a pariah. And, far from contemplating peace with the Kurdish rebels, he seems to relish the resumption of war with them.

Unfortunately, this is a winning strategy. Keeping the country on high alert against perceived enemies and inflaming nationalist-religious passions serves to keep Erdogan’s base mobilised. And it neutralises the two main opposition parties; both are highly nationalistic and therefore constitute reliable allies in the war against the Kurdish rebels.

Similarly, Erdogan’s offensive against Gülen and his movement seems driven more by political opportunism than by a desire to bring the coup’s organisers to justice. Erdogan and his ministers have endlessly griped about the United States’ reluctance to extradite Gülen to Turkey. Yet, nearly two months after the coup, Turkey hasn’t formally submitted to the US any evidence of Gülen’s culpability. Anti-American rhetoric plays well in Turkey, and Erdogan isn’t beneath exploiting it.

In his testimony to the prosecutors investigating the coup, the army’s top general has said that the putschists who took him hostage offered to put him in contact that night with Gülen. This remains the strongest evidence that Gülen himself was directly involved. A leader intent on convincing the world of Gülen’s culpability would’ve paraded his military chief in front of the media to elaborate on what happened that night. Yet the general hasn’t been asked—or allowed—to speak in public, fueling speculation about his own role in the attempted coup.

And so Turkey’s never-ending cycle of victimisation—of Islamists, communists, secularists, Kurds perennially, and now the Gülenists—has gained velocity. Erdogan’s making the same tragic mistake he made in 2009–2010: using his vast popularity to undermine democracy and the rule of law rather than restoring them—and thus rendering moderation and political reconciliation all the more difficult in the future.

Erdogan’s twice had the chance to be a great leader. At considerable cost to his legacy—and even greater cost to Turkey—he spurned it both times.

Dani Rodrik, Professor of International Political Economy at Harvard University’s John F. Kennedy School of Government, is the author of Economic Rules: The Rights and Wrongs of the Dismal Science. This article is presented in partnership with Project Syndicate © 2016.