“There will be some political instability, but that is part of the rules of the game,” said Sinan Ulgen, the chairman of the Center for Economic and Foreign Policy Studies, a research institution in Istanbul. “But fundamentally I don’t think this will be a protracted period of instability, essentially because the opposition parties are hungry for power.”

As Turks faced an uncertain political future, many on Monday also celebrated what amounted to a stunning outcome to the elections: the first major electoral setback for their powerful president.

Many Turkish voters, including some longstanding supporters of Mr. Erdogan, seemed finally to have had enough of their president’s abrasive style. Mr. Erdogan followed a familiar script throughout the election campaign, using the language of Islam to whip up support among his religious base and denouncing critical voices as enemies of the state. His most ardent supporters lauded him as a figure almost as consequential as the Prophet Muhammad himself, deepening many Turks’ sense that a personality cult had enveloped their president.

“He thought previous formulas he had used — painting the opposition as terrorists, traitors and infidels, and throwing in Israel and the interest lobby and the big bad West — would work,” said Asli Aydintasbas, a Turkish columnist and analyst for CNN Turk. “But people had heard of this for a long time, and they were tired.”

As president, Mr. Erdogan himself was not on the ballot. But the defeat almost certainly stymied his ambition to push forward with a new constitution and to consolidate power in an executive presidency.