For a country where dictatorship had been widely mentioned as a threat, Turkey’s general election showed that, for the short term at least, democracy is in vibrant shape (see Sunday’s preview here). The incumbent Justice and Development Party (AKP) suffered a major defeat, losing its parliamentary majority with an adverse swing of 9.0%. The three opposition parties will have 292 seats between them to the AKP’s 258.

Prime minister Ahmet Davutoğlu has tendered his resignation, but will remain in office in a caretaker capacity until a new government is formed.

Mathematically, there are four routes to a majority: an alliance of the AKP with any one of the three other parties, or a combination of the three, excluding the AKP. None of the four possibilities seems at all likely to be able to sustain a coalition government, but it’s possible that some less formal arrangement will allow a minority government to function rather than have Turks return to the polls (which would be unlikely to solve anything).

Apart from their hostility to the AKP, the three opposition parties have almost nothing in common. The largest, the CHP, is secular, nationalistic and centre-left in orientation; the MHP is ultra nationalistic, even neo-fascist, but with a religious tinge; while the HDP (which won as many seats as the MHP with a slightly smaller but more concentrated vote) is left-wing – “civic republican” as my colleague Guy Rundle has it – and based heavily in the separatist Kurdish population.

Just watching the dynamics of having them in the same room together, much less trying to form a coalition, would be a real spectacle.

The one combination that’s clearly not possible is co-operation between the AKP and the CHP. But either the MHP or the HDP is a possible (if informal) partner for the AKP: the MHP appealing to its conservative religious side, the HDP to its more reformist side, and especially to its project of peace with the Kurdish independence fighters, the PKK.

Alternatively, one can imagine a CHP minority government that the MHP and the HDP, despite their mutual hostility, would both support, at least as a temporary measure to dismantle some of the AKP’s incipient authoritarianism.

Unfortunately, the immediate arbiter of these choices is the president, AKP supremo Recep Tayyip Erdoğan, who transferred to that office from the prime ministership only last year. While his ambitions for a more powerful executive presidency have clearly received the thumbs down, Erdoğan will hardly be a neutral force in the post-election manoeuvring. His influence will undoubtedly be exerted to keep the AKP in power.

But the essence of a parliamentary system is that ultimately the decision is in parliament’s hands. If the opposition parties can agree on who should be in office, and insist on it on the floor of parliament, the president in the end will have to accept that – unless he is willing to resort to extra-legal means, and Erdoğan so far has shown no sign of that.

So although Turkish democracy looks lively right now, the next few weeks or months could put it to a severe test.

(Visited 19 times, 1 visits today)