Selahattin Demirtas, co-chair of the pro-Kurdish Peoples' Democratic Party, (HDP) arrives for a news conference in Istanbul on Sunday. (Lefteris Pitarakis/Associated Press)

“THE DEBATE about dictatorship is over. Turkey narrowly averted a disaster.” So spoke a triumphant Selahattin Demirtas, the leader of the country’s pro-Kurdish party, after a historic election Sunday. He might have been premature. The vote gave the Kurds their first parliamentary bloc and denied a majority to the ruling Justice and Development Party (AKP) of President Recep Tayyip Erdogan; it was, indeed, a decisive rejection of Mr. Erdogan’s drive to consolidate autocratic power. But it remains to be seen whether the man who has dominated Turkish politics for the past dozen years will accept his defeat.

Mr. Erdogan, who has successively attacked the military, the judiciary and the media as he has grown more ambitious, hoped the parliamentary vote would provide his party with a supermajority that would allow him to rewrite the constitution so as to concentrate powers in the presidency, the mostly ceremonial post Turks elected him to last August after three terms as prime minister. This Putinesque move produced a broad backlash from Turkey’s diverse and increasingly middle-class voters, who turned out in droves — turnout was reported to be 85 percent — to support opposition parties. Mr. Demirtas’s People’s Democratic Party passed the 10 percent threshold to join three other opposition parties in parliament, leaving the AKP, which received less than 41 percent of the vote, nearly 20 seats short of a majority.

A logical response to this defeat would be for Mr. Erdogan to drop his power grab and look for ways to compromise with opponents. The AKP could form a coalition government focused on reviving the economy, which has faltered in the past year after a decade of strong growth. It could validate the historic embrace of democracy by the Kurdish minority by accelerating the completition of a peace settlement with armed insurgents.

Mr. Erdogan, however, may be tempted to maneuver around his rebuff. If it does not form a government in 45 days, and the opposition does not unite in its own coalition, the president’s party could trigger new elections. That could give Mr. Erdogan another chance to win over former AKP voters, push the Kurdish party below the threshold for parliamentary representation and scoop up most of its seats. Several party officials told Reuters on Monday their most likely course would be to prepare for another campaign, perhaps after a brief spell of minority government.

That sounds like a recipe for sustained instability in a country that can ill afford it, perched as it is on the border of the war zone encompassing Iraq and Syria. A period of turmoil could, in the end, benefit Turkey if the result is to defang an autocracy-in-the-making. But better that Mr. Erdogan accept now that he must change course.