The attempted coup in Turkey on July 15, 2016, could have been a promising moment, one that encouraged President Recep Tayyip Erdogan to pursue a decidedly more democratic path. He could have used the opportunity to educate his citizens on the merits of electoral, rather than military, solutions to political conflict. After every major opposition party came out against the coup attempt, he could have seized the moment to build unity and emphasize that even amid partisan political differences, most Turks share a commitment to democratic practices. He could even have brought some other parties into his government to ensure their shared stake in preserving democracy. But this has not happened, and will not happen. And for good reason: Even if such moves would be good for Turkey, they’re not good for Erdogan himself.

For those committed to democratic ideals, it is tempting to think that political success is derived from appealing to the many and delivering the policies most people want—that is, from trying to make the world, or at least one’s own country, a better place. But if the chief goal of politics is, instead, to seize and remain in power, then democracy is not a politician’s friend. From this perspective, rather than appealing to the many, the truly successful politician devises means to be beholden to as few people as possible. The fewer the number of people whose loyalty is required, the easier it becomes to keep such supporters happy, even at the expense of society—and thus to keep control indefinitely.

Erdogan is adept at replacing opponents with lackeys, and the failed coup gives him another opportunity. If “success” means holding onto power, Erdogan’s best response may very well be the one he’s chosen: detaining, arresting, or firing those who participated in the coup, along with a broad swath of his political opponents. Indeed, he has already charged more than two dozen senior officers with treason and purged more than 60,000 members of the police, judiciary, and civil service. For him, the only real question is how much purging is too much.

From one perspective, political purges—essentially, the sudden removal of rivals, real or perceived—appear short-sighted. In Turkey’s case, one could argue that Erdogan’s decision to detain or dismiss thousands of members of his own civil service could stoke a backlash against him, creating a broad coalition of newly jobless soldiers and bureaucrats to oppose his leadership. And indeed, the current purges do not augur well for Turkey in the long run. But for leaders like Erdogan, the long run is no further off than the next threat. In the aftermath of a genuine, though unsuccessful, attempt to overthrow him from inside his own military, Erdogan evidently sees these threats everywhere. The best way to suppress them is to isolate or even eliminate the opposition.

For petty dictators like North Korea’s Kim Jong Un, who make no pretense of being democratic leaders, this is an easy task. It’s much harder and more distasteful to eliminate opponents in democratic societies, given their independent judiciaries and long lists of personal freedoms, which limit the ability of leaders to eliminate their opponents. The Angela Merkels and Justin Trudeaus of the world are, for the most part, in no position to purge their foes. Leaders of quasi-democracies like Turkey, Russia, Venezuela, Iran, Ukraine, or Pakistan, by contrast, can and do get away with just such suppression.

Although the personal consequence of being overthrown via coup or revolution is typically much worse than the aftermath of electoral defeat, the probability of being ousted from power is low except in genuine democracies. Indeed, the average democratic leader remains in office only about half as long as the average autocrat, monarch, or junta leader. If autocrats make it past the first couple of years, they generally do not fall from power until old age or terminal illness bring them down. But even incumbent politicians in mature democracies try to curtail democracy, albeit in much milder ways, when possible. In the United States, for example, politicians engage in gerrymandering and restrictions on voter registration, to reduce the odds of defeat. Places with only quasi-legitimate elections, like Russia, Venezuela, Iran, or Turkey, diminish the opposition more forcefully, for example by controlling the press and by greatly restricting freedom of assembly.

In Turkey, the freedoms that ensure real democracy—elections, alone, are insufficient—have eroded in recent years. In Freedom House’s recently published report on press freedom, for example, Turkey’s media climate is listed in the bottom ranks—“not free.” Places like Zimbabwe and Libya also receive the same dismal ranking, as do Venezuela, Russia, Iran, and Pakistan. Once the opposition’s freedoms are so restricted that elections become largely ceremonial, coups or rebellion become the primary remaining paths for political change. The odds of being ousted through a coup or rebellion are probably no worse than the odds of losing reelection.

Indeed, in the June 2015 election in Turkey, Erdogan suffered a serious, though not politically fatal, setback. For the first time since 2002, his party failed to secure a parliamentary majority. While in a truly democratic society, such an electoral repudiation would have prompted policy adjustments to satisfy more constituents, for Erdogan it meant culling opponents more aggressively, and then calling for another election. Amid accusations of vote fraud and electoral violence, Erdogan’s Justice and Development Party won a majority in November 2015.

After that, anyone watching Turkish politics knew Erdogan intended to keep purging, especially after he saw his support base erode through the rest of 2015. The remaining non-loyalists in the military must have known their days were numbered. And among the many reasons the coup last Friday did not succeed was Erdogan’s own success in ensuring the loyalty of the military’s general staff.

By taking to the streets at Erdogan’s request, the Turkish people revealed their preference for a deeply flawed democracy over no democracy at all. And a deeply flawed democracy is just what they will get. Giving them more democracy would only harm Erdogan's future ability to stay in power; hence, he is unlikely to liberalize now. Instead, he’s likely to expand the purge, shrink his coalition down to its essential core, use patronage to reward its members, and push Turkey further from democratic rule. Replacing military elites with his lackeys may diminish the threat of future coups. Removing impartial judges makes it even harder for journalists to write critically about government corruption without being jailed.

Erdogan’s strategy, however, comes with its own risks. If he purges too few people, leaving a rump of the organized opposition still in business, then he faces a period of prolonged instability. Suppression then becomes an ongoing activity in which his regime continually fine-tunes its actions to prevent the opposition from rising again, which inhibits his government’s ability to do much else. For example, despite undertaking massive attacks on the Muslim Brotherhood in Egypt since seizing power in 2013, President (and former General) Abdel Fattah el-Sisi has found it necessary to engage in just such fine-tuning, making it difficult for his government to implement promised reforms to get the economy back on track.

But purging too many could be even more dangerous for Erdogan. When a strongman’s effort to dispose of his rivals becomes overzealous, he invites the danger of ensnaring genuine loyalists, gradually building a network of dangerous opponents. Such was the case with Iraqi Prime Minister Nouri al-Maliki, whose behavior got him replaced by 2014. And, indeed, if alleged opponents are uncovered by a network of snitches, the purger runs the risk of conflating an informant’s personal animosity toward the accused with evidence of actual disloyalty. When loyalists are caught up in wide purges, then every loyalist may come to think he is at risk. In such an environment, individuals have a great incentive to mobilize a mass rebellion or yet another coup to bring down the regime. This may well have been Robespierre’s error in France during the Reign of Terror, in which he sent people to the guillotine so indiscriminately that loyalist revolutionaries turned on him, fearing they might otherwise be next. Once the loyalists no longer believe their best course is to fight for the regime, the incumbent leadership is likely to fall. Erdogan, consequently, must strike the right balance between purging opponents and nurturing—not targeting—loyalists in order to secure his position, both internally and internationally.

One possibility is that as Erdogan’s government grows more authoritarian, it raises the danger of Turkey’s own eventual purging from NATO. U.S. Secretary of State John Kerry and others have reminded Erdogan that NATO members must be democratic. Such admonitions, however, are unlikely to influence Erdogan. He knows that Turkey is critical to NATO’s efforts to pressure Assad and stabilize the region. Turkey is similarly critical to the European Union’s desire to limit the flow of people emigrating from Syria. Thus, Erdogan can count on his leverage to limit European and American complaints to little more than words. As he as said in the wake of the failed coup: “We will continue to cleanse the virus from all state institutions.” The world can and should take him at his word.