This election seemed to allow Erdoğan to eat his cake and have it too: On the one hand, the control he exerted over key institutions, such as the country’s electoral commission, had limited the risk the election posed to his rule. On the other hand, the election helped to shore up his legitimacy at home and abroad. Even though observers from the OSCE to Freedom House emphasized that the election was not free and fair, international leaders including Angela Merkel and Donald Trump publicly congratulated Erdoğan on his “victory” at the polls. As Timur Kuran, a Turkish expert on authoritarian regimes, put it, Erdoğan sought to combine “the illusion of a contested election” with “a predetermined outcome.”

Read: How Erdoğan made Turkey authoritarian again

The tremendous power Erdoğan now holds makes it all the more remarkable that a united opposition was, last month, able to gain an unexpected set of victories in the country’s municipal elections: Exploiting anger at Turkey’s growing economic crisis, and fielding a new crop of candidates who are both charismatic and conciliatory, the opposition pulled off two highly symbolic upsets, winning control of the country’s capital, Ankara, as well as its largest city, Istanbul.

As a result, Erdoğan has, for the first time since the failed coup three years ago, faced a real trade-off: Would he allow the election results to stand, thereby acknowledging the public’s growing discontent with his rule? Or would he exploit his hold over Turkey’s institutions to have the election annulled, making it blatantly clear to anybody who cared to look that Turkey is no longer a democracy?

For much of the 20th century, the most acute threat to democracy came from the barrel of a gun. When democratic systems collapsed, it was usually because tanks commandeered by the leader of an openly antidemocratic movement rolled up in front of the country’s parliament or presidential palace. Javier Cercas vividly describes such a coup attempt in the opening pages of The Anatomy of a Moment, his account of a failed putsch against Spanish democracy in 1981:

Pistol in hand, Lieutenant Colonel of the Civil Guard Antonio Tejero calmly walks up the steps of the dais, passes behind the Secretary and stands besides the Speaker Landelino Lavilla, who looks at him incredulously. The lieutenant colonel shouts: “Nobody move!”, and a couple of spellbound seconds follow during which nothing happens and no one moves and nothing seems to be going to happen to anyone, except silence … Four nearby shouts, distinct and indisputable, then break the spell: someone shouts: “Silence!:”; someone shouts: “Nobody move!”; someone shouts, “Get down on the floor!”; someone shouts: “Everyone down on the floor!.” The chamber rushes to obey.

Because it makes for such striking theater, the kind of open attack on democracy that Cercas describes has had a long-lasting hold on the political imagination. But in the 21st century, coups have become rarer. From Russia to Venezuela, the strongmen who have destroyed democratic institutions won high office at the ballot box. Far from openly attacking democracy, they have tended to argue that they, and they alone, truly represent the people.