By definition, municipal elections are about choosing local leaders. Yet Turkey’s local elections this weekend will be about much more. It is set to be a contest between two visions of democracy and its outcome will have serious implications for the future of democratic freedoms in this crucial western ally.

For Recep Tayyip Erdogan’s ruling AK party, an initial decade of relative calm ended with the protests focused on Gezi park on Istanbul’s Taksim Square last year, which led to a nationwide mobilisation against the prime minister’s polarising and paternalistic style. More recently the government has faced fresh pressure following a wave of corruption allegations, leaked mostly almost on a daily basis through social media.

The prime minister’s response to these challenges – besides banning Twitter and YouTube – has been to sidestep criticisms by emphasising his government’s legitimacy to rule the country. While campaigning for his local candidates, Mr Erdogan has stressed the importance of the national will, reiterating his belief that the primary source of legitimacy for governments is elections. This is also the reason he has opted to turn the local polls into a referendum on him and his AK party.

But the real importance of the local elections will rather be in determining the next phase of Mr Erdogan’s political stratagem, and therefore of Turkey’s near-term political path. Depending on the outcome of the local elections, the prime minister might decide to become a candidate in presidential elections scheduled for August. His party would need to get close to the 50 per cent it received in the 2011 parliamentary elections for him to consider this option seriously. Failing this, he would want to lead his party in the parliamentary elections scheduled for 2015.

Changing the AK party’s bylaws that stipulate a three-term leadership limit would enable him to continue his political career. A third scenario that cannot be ruled out is the AK party registering a substantive drop in support to, say, 35 per cent. That would force Mr Erdogan to spend his political capital in the near term to ensure the cohesion of his party in the face of an increased risk of internal dissent.

For Mr Erdogan, the second pillar of his legitimacy is the evidence of his government’s performance. That is why his campaigning for his party’s local candidates is laden with references to roads built, social programmes launched and surges in welfare that have been realised under his rule. But what he fails to take into account is “process legitimacy” – which is incidentally the source of Turkey’s recent instability.

Unlike Mr Erdogan’s standards of democratic legitimacy, which are structural, process legitimacy is behavioural. It concerns the way the rule of law is applied, transparency in decision making is implemented, media freedoms are protected and wider participation in policy making is ensured. Process legitimacy is also intrinsically linked to the ability of the political system to permit and respond to dissent. For liberal democracies, process legitimacy is as important as the other pillars of democratic legitimacy. That is fundamentally what distinguishes liberal democracies from illiberal ones.

Mr Erdogan’s refusal to adopt a more conciliatory stance during the Gezi protests last year and, more recently on the allegations of corruption, is linked to his genuinely held belief that a ballot box victory combined with a sound economic performance is not only necessary but also sufficient to preserve his rule. But he is wrong.

Turkey’s democracy has matured beyond the point of accepting this shallow version of a democratic contract. Mr Erdogan may still be the most popular politician in the land but his government is losing legitimacy each day that it refuses to implement fully the rule of law and to bring more transparency to policy making. That is why political instability in Turkey can no longer be appeased just by winning elections. Even if Mr Erdogan’s AK party wins the next elections, and wins big, this popular discontent will not go away.

The only way forward for the Turkish government is to recognise and address this critical shortcoming in its interpretation of democratic legitimacy. The EU can play a constructive role in nudging the government towards a more ambitious and comprehensive agenda of democratic reforms by starting talks on fundamental freedoms as part of the accession negotiations.

The crisis in Ukraine epitomises the dangers inherent in social and political polarisation. Turkey faces a similar challenge that can be overcome only by a wider interpretation of democratic legitimacy that goes beyond the deification of the ballot box. Only once this has happened can Turkey make the transition from the purgatory of unfulfilled democracies to the promised land of genuinely liberal democracies.

This article was originally published in the Financial Times.