Garvan Walshe is a former National and International Security Policy Adviser to the British Conservative Party. He runs TRD Policy.

Turkey’s Erdogan finds himself in trouble. After the Maidan toppled Yanukovich in Ukraine, his became the most advanced of the facade democracies, where the outward forms of democratic practice are preserved but emptied of content. There are courts, but judges are carefully vetted. There is media, but even when it’s privately owned, it depends on the government or its supporters for advertising. There is civil society, but it is starved of funds. There are economic regulators, but their members are politically beholden. There’s a private sector, but success in business depends on the forbearance of those regulators. What there must be, however, are elections.

Because Erdogan does not consider himself a dictator. He derives his legitimacy from prevailing against the opposition in a fight that isn’t transparently fake. He tilts the playing field in his favour but can’t get away with tying both the opposition’s hands.

He harasses the opposition, closes their newspapers, intimidates their financial backers, orchestrates prosecutions of academics and filmmakers for opposing his adventurism in Syria, but he has to allow them to campaign. His victories in recent elections and referendum campaigns came by uncomfortably close margins. Faith in the election results is far from universal.

But last week in Istanbul and Ankara the voters sprung a surprise. Despite an initial proclamation of a government victory by the state news agency, the opposition CHP’s candidates (Republican People’s Party) won, and recounts demanded by the Erdogan’s AKP failed to change the result.

Though the AKP had only held Ankara, the capital founded by secularist Ataturk, since 2014, Istanbul, where Islamist Erdogan was himself mayor between 1994 and 1998, and which the AKP have held since 2004, is a different matter. Its importance is far more than symbolic.

Istanbul is where the AKP has ruled for 15 years, it is also where their patronage networks are most developed. The city’s budget amounts to some $8 billion a year. Its finances, and those of the taxpayers who pay for it, have come under severe pressure as the Turkish lira has fallen due to Erdogan’s repeated attacks on the central bank, foreign investors and, in an anti-Semitic dog whistle, “the interest rate lobby.” Defeated AKP mayor Binali Yildrim warned voters that taxes would have to “rise.”

Istanbul´s voters however, increasingly suspect skulduggery. How much of their money has disappeared, they ask, after 15 years of AKP control of the city, in padded public contracts awarded to AKP cronies? An opposition-controlled mayoralty will be able to look at the books and find out.

Corruption — theft from citizens — is where facade democracies come unstuck. It is where abstract worries about the rule of law are revealed in uncollected rubbish, understaffed schools and hospitals and take solid form in property developers’ building on public space and rezoned land.

The new mayor, Imran Imamoglu, can now turn this to his advantage. He is in a position to expose 15 years of graft and implant into every Turk’s head the thought: ‘If this is what they stole from Istanbul, how much did they take from the country?’

Meanwhile, within the AKP itself, Erodgan’s rivals are rattling sabres. Ahmed Davutogulu (former foreign minister) and Abdullah Gul (former president) are letting rumours of a break-away party and new parliamentary elections gather steam. The AKP lacks a parliamentary majority, and avoids a situation where Erdogan would have to “cohabit” with an opposition Prime Minister thanks to a confidence and supply deal with a nationalist, but non-religious, party, largely on the basis of shared opposition to Kurdish insurgency.

Erdogan is now pushing for repeat elections in both cities. In a sense he wants to repeat his gambit of 2015, when a second set of parliamentary elections allowed him to regain a majority that he lost in the first. But then he had the advantage that the opposition simply failed to coalesce against him, and normal procedures caused parliament to be dissolved and new elections held. This time he has to find a way of leaning on the Supreme Electoral Council to order a re-run without any justification other than that the “wrong” side won.

Telling people to vote again because they voted the “wrong” way the first time risks an almighty backlash. Even if he manages to coerce the council, it’s not clear the elections would deliver the results he needs.