Garvan Walshe is a former National and International Security Policy Adviser for the Conservative Party. He runs Brexit Analytics.

How did this happen? Just two years ago, Erdogan’s AK party had lost its parliamentary majority, and faced the unfamiliar prospect of opposition. Now he has purged the army, crushed his opponents, and is dismantling all institutional barriers to his complete control of Turkey.

His assets: the power that comes from holding office, and being expected to continue to do so; the weakness of opposition in his own party, and the self-indulgent infighting among his opponents.

Questions must be asked about a distinctly fishy referendum result, and the last minute decision by the Supreme Electoral Commission to accept 2.5 million unstamped ballot papers. Questions need also be asked about the speed with which the official state news agency announced results before the counting had finished.

This rigging, for that’s what it appears to be, looks alarmingly last minute. He thought he had arranged, through ceaseless propaganda, the suppression or bankruptcy (by denying advertising) of opposition newspapers, a healthy ten to fifteen point lead (that’s at least what pollsters had been expecting).

Despite the failed coup against him; despite, too, the purges of the media, universities and the army, the fundamental division in Turkish society, between the AK – religious, conservative, paternalistically pro-business – and its opponents, has stayed exactly where it was in 2015. Turkey, like, it seems, so many other countries, is divided 50/50. Erdogan’s strength comes from his being able to unite half the country around himself, while his opponents bicker.

The main division in the opposition was between the secular, but very Turkish nationalist, MHP, and the Kurdish HDP. In British terms, imagine a government that could only be toppled by a coalition involving UKIP and the Lib Dems. Erdogan exploited this split, and a surge in pro-Kurdish terrorist attacks, in elections called that September after no government was formed. Like leftists who refused to vote for Hillary “because of her emails”, the Turkish nationalists couldn’t contemplate a compromise with the Kurds.

Unlike his opponents, Erdogan understood the importance of power. Since winning his first election in 2003 he has allied with, and then discarded, democratic Turks against the army, business against the left, the Gulen movement against the army, the Kurds against the army, the MHP against the Kurds, the loyal members of the army against the Gulenists, and finally the MHP against what’s left of the secular opposition. After each round he emerged stronger, at liberty to persecute and even imprison his former allies. He used them to accumulate authority, then betrayed them in his own interest. They thought they could benefit from allying with him, and made a huge mistake.

Even after this referendum, it was clear the opposition wasn’t prepared for an attempt to rig the vote. Opposition parties will contest the result in the courts, but with the judiciary having been heavily purged that probably won’t make much difference.

They needed to have been ready to put their supporters in the streets of the main cities, all of which were “No” strongholds and demand recounts, and perhaps the invalidation of the result; meanwhile contesting the result on international media. Too many Western outlets uncritically accepted the official news agency’s premature declarations of a solid “yes” victory.

The real lesson, however, is as old as Machiavelli. She who wants to reform her state needs to take the opportunities available and seize the initiative. You shape events by taking risks, while the people who wait for events end up being shaped by them. The price of risk is of course utter failure, and failure will eventually come for Erdogan. By seizing power in this way, the chance of him dying peacefully in his bed has got much lower indeed.