ISTANBUL, Turkey — Celebrations erupted in Turkey after election results confirmed what many thought they’d never see: the country’s powerful and omnipresent leader President Recep Tayyip Erdogan suffering a resounding defeat.

There was a sense of disbelief on social media too, where Turks, who had started to lose faith in the system, rejoiced that "democracy won."

On Monday, messages of hope circulated on social media. "What a beautiful morning," one teacher wrote on Facebook. "A new day, a new week, another chance for democracy," another tweeted.

Erdogan has been the face of Turkish politics for more than a dozen years. For those who live in Istanbul, his influence stretches back even further to his time as mayor of the city two decades ago. Many can’t remember a time when he wasn't in charge.

A man walks past a billboard with a picture of Turkey's President Recep Tayyip Erdogan, in Istanbul, Turkey, Monday, June 8, 2015

He is deeply beloved by his base, which has helped keep him in power for so long. But over time, his enemies have multiplied as he has trampled critics and broken the rules, daring opponents to do something about it "at the ballot box."

Until Sunday nobody could.

Again and again he stood in the way of democratic challenges to his power. When millions protested against him in the spring of 2013, Erdogan cracked down. When journalists and the judiciary launched investigations into corruption allegations against him, he silenced them by firing or reassigning thousands of police officers, judges and prosecutors. His personal lawyer, meanwhile, went after scores of journalists and ordinary social media users, accusing them of insult and slander.

A man reads a newspaper at a kiosk, featuring front-page coverage of Sunday's elections, in Istanbul, Turkey, Monday, June 8, 2015.

Even when he exhausted his term limits as prime minister last year, Erdogan found a way to hang on and ran for the less powerful presidency. His opponents' uninspiring campaigns only added to Erdogan’s advantage of being the most influential and powerful figure in the country. He swiftly defeated them at the polls after a lopsided campaign season that saw little attention on any candidate but him. On election day, some voters couldn’t recall his opponents’ names.

Watchdog groups raised concerns and critics sounded off, but they received little but defiance in return. Over accusations that he was above the law, Erdogan made a bid for additional powers. He argued that the country needed a strong, executive-style president. As if preparing for his new role, Erdogan moved into a palace nearly 30 times the size of the White House.

His ruling party needed to win enough seats in Sunday’s parliamentary elections to write the expanded power changes into law and, ahead of the vote, Erdogan continued to break the rules. Although presidents in Turkey are supposed to be politically neutral, he was a consistent presence on campaign trail, where he bashed the opposition and sung the praises of the ruling AKP.

This time, however, his opponents were determined. Many voters said they did not cast their ballots for their preferred party, but for the party most likely to stand in Erdogan’s way.

They all had their reasons to want him out. But what unified them was a sense that the man had too much power for too long and it was time for him to be stopped. When the results rolled in and showed that the party indeed fell short of a supermajority for the first time since its founding in 2002, there was a collective sense of disbelief.

People celebrating in the streets of Diyarbakir, Turkey, after elections on June 8, 2015.

Social media filled with declarations of shock and relief that democracy was still alive in Turkey.

I just can't believe my eyes still https://t.co/cukt2ix2MH — Esin E. (@esi_ee) June 7, 2015

Election results have redeemed #Turkey's credibility.So proud of my country #TurkeyElections — Amberin Zaman (@amberinzaman) June 7, 2015

Pro-Kurdish, pro-women and pro-equality HDP now stands at 13 percent. Much higher than expected. New Turkey this is. But not Erdogan's. — Kerem Oktem (@KeremOxford) June 7, 2015

An added surprise was that the party that starved the AKP of its extra votes was one that grew out of the Kurdish movement — a remarkable step forward for a country that has had a history of conflict with its Kurdish minority.

From Istanbul to the Kurdish-majority city of Diyarbakir, revelers poured into the streets.

People celebrating in the streets of Diyarbakir, Turkey, after elections on June 8, 2015.

To be sure, the AKP still came out on top, notching 40% of votes. But it was a significant slip from the last parliamentary elections in 2011 when the AKP won 50%. It also marks the first time in the AKP’s history that it will not have enough seats to govern as a single party.

What this means for Turkey remains to be seen. But if only for a moment, those who wanted to curtail the president are letting the victory soak in.