On the streets of Kasimpasa, the gritty conservative Istanbul neighbourhood where Turkish president Recep Tayyip Erdogan grew up, the news that his AK Party had lost its parliamentary majority in elections last week was not seen as entirely negative. "Erdogan needed a reality check," said one young man. "But I still support the AKP."

In a result that has been hailed as another milestone for Turkish democracy, Mr Erdogan's Justice and Development Party, known by its Turkish initials as the AKP, was delivered a stern rebuke by voters who made clear their unease over his drift towards authoritarianism. While Mr Erdogan, as president, did not run in the election, his party's drubbing will act as a brake on his controversial push towards a new constitution which would consolidate power in an executive presidency.

Both Turkey and Mr Erdogan have changed dramatically since he was first elected prime minister in 2003. Then considered a reformer with Islamist roots, Mr Erdogan initially steered Turkey in a direction many believed would lead it more swiftly into the EU. He opened up the economy, granted new rights to the long-suppressed Kurdish minority and made Turkey's devout masses feel more included than they had under the military-backed secular elite that had dominated the country for decades. Western leaders talked of how "The Turkish model" could inspire other Muslim-majority countries in melding democracy with Islam.

But as his power grew, Mr Erdogan became more authoritarian and abrasive. He threatened to ban social media and targeted so many journalists that in 2012, there were more media personnel in jail in Turkey than anywhere else in the world. After serving three terms as prime minister, he was elected president in 2014, a post ostensibly less powerful but in reality Mr Erdogan remained the main player. As he set about developing what amounted to a cult of personality, an increasingly megalomaniacal Mr Erdogan dismissed any critics as part of a conspiracy against him.

Mounting frustration with Mr Erdogan's autocratic ways erupted in summer 2013 when police cracked down on demonstrators opposing plans to replace a park in central Istanbul with a shopping mall. The violence - and Mr Erdogan's belligerent response - sparked rallies across Turkey, turning a protest over a park into public fury against the man many accused of acting like a sultan of old who tolerated only those who agreed with him. A series of corruption scandals implicating high-level officials shook the AKP later that year but failed to curb Mr Erdogan's excesses. The unveiling of a new 1,150 room presidential palace - at a reported cost of $350m - was seen as yet another sign of hubris. Turkey's EU prospects grew dimmer as Brussels expressed concern about the country's trajectory and observers expressed dismay that Mr Erdogan had turned into something like a Turkish version of Russia's Vladimir Putin.

Unswayed by his critics, Mr Erdogan was bullish in the run-up to last week's elections, at one point predicting a resounding AKP victory that he said would be comparable to the Ottoman conquest of the Byzantine Empire. Turkish novelist Elif Shafak described the poll as "the most stressful Turkish election in recent memory" and noted that "In no other ballot had so much been at stake."

That was the reason why many chose to vote tactically, including several who had previously voted AKP but felt a message needed to be sent to Mr Erdogan. Their votes went to the Peoples' Democracy Party (HDP), a Kurdish-based party which subsequently made history by becoming the first such party to win seats in the Turkish parliament.

The AKP remains a formidable force in Turkey's politics. It may have lost its majority but it still secured more seats in parliament than any other faction.

Mr Erdogan's wings have been clipped, however, and his ambitions to rewrite the constitution will likely founder without the votes to back it up. Turkey now faces what could be a rocky period of coalition politics, something reflected in the tumbling of the Turkish lira and the country's stock market soon after the election results were declared. Whatever government is formed faces an array of daunting challenges including an economy that has gone from booming to slacking, a stalled peace process with the Kurds and the impact of a war that rages with no end in sight next door in Syria.

The question of EU membership no longer occupies the space it used to in Turkey's public debate, partly due to disillusionment on the Turkish side.

That may change if Mr Erdogan learns the lesson of these elections and the new government strives to stake a very different path forward. Turkey has shown it can still act as something of a model to others in the region - even if an imperfect one.

Irish Independent