It may be that Erdogan simply overreached in the last few years. While he’s Turkey’s most popular and powerful leader in decades, his eagerness to expand his reach alienated voters, particularly urban and secular ones. He embarked on a $615 million white-elephant palace project, imprisoned and intimidated the press and his political opponents, tried to block YouTube and Twitter, and feuded with Fethullah Gulen, a religious leader who’d help bring him to power. Anger boiled over in the streets of Istanbul and elsewhere in 2013, sparked by protests over trying to turn a park in the city into a mall. Meanwhile, the economy sputtered.

Rounding out the rest of the vote on Sunday, the secular-nationalist Republican People’s Party (CHP) won 25 percent; the right-wing Nationalist Movement Party (MHP) took 17 percent; and the HDP ended up at 12.5 percent. To change the constitution, the AKP would need 367 seats; a majority would have been 276. Instead, it’s projected to take 258.

An AKP official told Reuters, “We expect a minority government and an early election." The party could seek a coalition government instead, but its prospects aren’t great. The CHP, its main rival, and HDP have both ruled out coalitions—not that they were likely in the first place. The MHP seems like a more natural partner, but the AKP isn’t interested, the same official said glumly: "If there is an AKP-MHP coalition, then we will not be able to achieve even this level of votes at the next election.”

The party tried to play up fear of a return to the bad old days of coalition governments, instability, and coups as a way to earn support. The stability of the last decade has been one of Erdogan’s great selling points. But his wily political maneuvering means it’s tough to count him out yet.

Despite fears, the day of the election seemed generally calm. That hadn’t been true of the campaign. On Friday, an explosion at an HDP rally killed two and injured more than 100. The rally was in Diyarbakir, a southeastern, mostly Kurdish city. Authorities haven’t placed blame for the attack.

It’s almost hard to recall that only a few years ago, Erdogan, a moderate Islamist, was viewed by both Western allies and reformers in Arab countries as a model for Muslim democracy. As a NATO ally in the Middle East, he’s been an important part of various security questions. But as he seeks more power, Erdogan has feuded with Western countries, who no longer see him as the reliable and trustworthy ally they once did. He’s steadfastly refused to get involved in the Syrian civil war, though fighters have streamed across the Turkish border into that conflict, and fighting erupted just over the border in Kobani. Disapproval of his handling of that conflict help build support for the HDP. How large an effect the election has on Turkey’s role as a regional power remains to be seen.