An awful lot is riding on the outcome of the presidential contest in Turkey, which Abdullah Gul, the foreign minister with an Islamist past, has re-entered - to the consternation of the overmighty generals who transformed his earlier candidacy into a summer-long constitutional crisis.

It is hard to think of any greater geopolitical imperative today than to demonstrate that Islam and democracy can be bound successfully together. Turkey is well on the way to proving this, in an experiment that is resonating far beyond its borders.

It is the Turks, of course, who are responsible for the success of this great challenge. But their partners in Europe and Nato must rise to it too.

The crisis erupted in April after the army issued an elliptical ultimatum - on its website - against Mr Gul's candidacy, in effect saying Turkey's secular heritage could not be entrusted to a man who had entered politics as an Islamist and whose wife wears the Muslim headscarf.

The ruling Justice and Development party of Recep Tayyip Erdogan, the charismatic prime minister, called early elections and was returned with a hugely increased share of the vote. Turks stood four-square with democracy as the generals tripped over their clumsy digital démarche.

Before the AKP emerged in late 2001, the army had ousted four governments - and closed four Islamist parties - in four decades. This resounding vote showedTurkey has changed and that ithas done so, to the horror of its cosmopolitan and secular elites, under a neo-Islamist banner. How did this happen?

Three reasons for the AKP's success seem to stand out.

First, it helps to be competent and to have a national project. When Mr Erdogan's party first won office in 2002 the nationalist right was a howling irrelevance, the left a museum-piece, and the liberal and social democratic centre had fragmented into shrinking personality cults for giant egos, cut off from the conservative heartland of Anatolia and, indeed, the lives of ordinary Turks they did so little to improve.

The AKP, by contrast, is a considered project. Recycled from the wreckage of two banned Islamist parties, liberally seasoned with mainstream conservatives and Turkey's new business class, Mr Erdogan and his friends did their homework while they were putting the party together. They interviewed 41,000 people nationally, learning that ties to Europe and an economy in the worst recession since 1945 overwhelmingly dominated Turkish concerns; headline issues such as headscarves came a distant ninth.

The AKP has since provided good governance, with high economic growth and stability, rocketing inward investment, 2.5m new jobs and near doubled per capita income, while raising spending on education and infrastructure. It has also, as part of Turkey's attempt to meet the criteria of European Union membership, presided over a constitutional revolution: abolishing the death penalty and criminalising torture, introducing democratic freedoms of expression and association and minority rights for the Kurds - and, above all, subordinating the army to civilian authority.

But a second reason for the AKP's success is its astute reading of the social transformation of the country. The party is now the chosen path to modernity of the socially conservative, religiously observant but at the same time dynamic and entrepreneurial middle classes of central Anatolia, who now demand their rightful share in power, hitherto monopolised by a self-perpetuating secular elite.

The AKP's appeal is aspirational, about giving people the chance to build fulfilling lives; but reassuring, by holding fast to the moorings of family, religion and the villages from which many Turks are just a generation away. In Islamist terms this is a traditionalist world-view that looks forward, rather than a radical outlook that harks backwards in a violent lament for past glory.

Many Turkish secularists know full well this is not theocracy by stealth; there is, indeed, a definite whiff of class animus in their resistance to the shift in the balance of power towards Turks from the provinces and the countryside. Their outlook is ossified. They are shrine-keepers for Mustafa Kemal Atatürk who, like many of those who built republican Turkey from the remains of the Ottoman empire, was a refugee, regrouping behind an essentially defensive political (and military) culture.

The AKP's third ace - and Turkey's - has been Europe. EU membership, finally under negotiation but now stalled, is still a popular and unifying idea in Turkey. Just about. Until reluctant partners such as France, Germany and Austria raised the bar for Turkish entry, the European project provided Turkey with not only an engine of reform but the glue of political cohesion. The Kemalists and military saw in the EU a fulfilment of the country's western vocation forseen by Atatürk, while the AKP saw in the EU's democratic club rules a shield against the generals.

Despite the maladroitness of its politicians, Europe's "soft power" is still seductive enough to arrange a marriage between Islam and democracy, bound by EU vows. Put another way, the interaction of Europe and Turkey is creating the Muslim world's first, as it were, Christian Democrats.

Like Christian Democrats in government across Europe, these Muslim Democrats differ from the mainstream centre-right - over moral issues or social justice, for instance - but they should be easy to recognise.

For all the hiccups and upsets, over free speech for writers perhaps, or free votes for a parliament that rejected a US invasion force for Iraq, they are a much better bet than the autocrats of the Middle East who, even when ostensibly enlightened like the Shah of Iran and his White Revolution, create social dislocation and bitterness that breeds extremism.

That is why Mr Gul's candidacy, following Mr Erdogan's democratic triumph, is a milestone in Turkey's political transition, perhaps akin to the 1982 Socialist landslide with which Spain's voters answered an attempted military coup by residual Francoism.

Europe should respond with enthusiasm to this and stop behaving as though the Turks were still menacing the gates of Vienna.

The assertion, especially in France, that Turkey shares none of Europe's heritage, is ahistorical: unless there was no Byzantium, no eastern Roman empire, no classics of Greek science and philosophy that, transmitted through the world of Islam, dragged Europe out of the dark ages. This is a country embedded in the history of Europe and Christendom as well as Islam - a precious commodity.