ISTANBUL — Turkish voters delivered a rebuke on Sunday to President Recep Tayyip Erdogan as his party lost its majority in Parliament in a historic election that thwarted his ambition to rewrite Turkey’s Constitution and further bolster his clout.
The results represented a significant setback for Mr. Erdogan, an Islamist who has steadily increased his power since being elected last year as president, a partly but not solely ceremonial post. The prime minister for more than a decade before that, Mr. Erdogan has pushed for more control of the judiciary and cracked down on any form of criticism, including prosecuting those who insult him on social media, but his efforts appeared to have run aground on Sunday.
The vote was also a significant victory to the cadre of Kurds, liberals and secular Turks who found their voice of opposition to Mr. Erdogan during sweeping antigovernment protests two years ago. For the first time, the Kurdish slate crossed a 10 percent threshold required to enter Parliament.
Mr. Erdogan’s Justice and Development Party, or A.K.P., still won the most seats by far, but not a majority, according to preliminary results released Sunday night. The outcome suggests contentious days of jockeying ahead as the party moves to form a coalition government. Already, analysts were raising the possibility Sunday of new elections if a government cannot be formed swiftly. Many Turks were happy to see Mr. Erdogan’s powers curtailed, even though the prospect of a coalition government evokes dark memories of political instability and economic malaise during the 1990s.
With 99 percent of the votes counted, the A.K.P. had won 41 percent of the vote, according to TRT, a state-run broadcaster, down from nearly 50 percent during the last national election in 2011. The percentage gave it an estimated 258 seats in Turkey’s Parliament, compared with the 327 seats it has now.
“The outcome is an end to Erdogan’s presidential ambitions,” said Soner Cagaptay, an expert on Turkey and a fellow at the Washington Institute for Near East Policy.
Almost immediately, the results raised questions about the political future of Prime Minister Ahmet Davutoglu, who moved to that position from that of foreign minister last year and was seen as a loyal subordinate of Mr. Erdogan.
Speaking Sunday night from a balcony at the party headquarters in Ankara, Mr. Davutoglu struck notes of triumph and optimism, touting his party as the winner because it won the most seats, without mentioning the loss of its majority.
“The elections once again showed that the A.K. Party is the backbone of Turkey,” he said.
Mr. Erdogan, who as president was not on the ballot Sunday, will probably remain Turkey’s dominant political figure even if his ambitions have been curtailed, given his outsize personality and his still-deep well of support among Turkey’s religious conservatives, who form the backbone of his constituency. But even among those supporters, including ones in Kasimpasa, the Istanbul neighborhood where Mr. Erdogan spent part of his youth, there are signs that his popularity is flagging.
“A lot of people in Kasimpasa have become disheartened by Erdogan’s aggressive approach in recent weeks,” said Aydin, 77, who gave only his first name because some of his family members are close to Mr. Erdogan. “I voted for the A.K.P. because it has become habit, but I think Erdogan lost votes this week.”
Turnout was 86 percent for the elections, which were seen as a referendum on Mr. Erdogan’s tenure, especially his plan for a presidential system that would have given him more power. Polling had consistently shown that the majority of Turks are opposed to the change.
By law, Mr. Erdogan can call for new elections after 45 days if a coalition is not formed, and the political uncertainty sent Turkey’s currency, the lira, to a record low against the dollar in after-hours trading.
The vote turned on the historic performance at the ballot box of Turkey’s Kurdish minority, which aligned with liberals and secular Turks opposed to Mr. Erdogan’s leadership to win almost 13 percent of the vote, passing the legal threshold for earning representation in Parliament.
Selahattin Demirtas, 42, a former human rights lawyer who leads the largely Kurdish People’s Democratic Party, told reporters Sunday night: “As of this hour, the debate about the presidency, the debate about dictatorship, is over. Turkey narrowly averted a disaster.”
The People’s Democratic Party, known as H.D.P., was able to broaden its base by fielding a slate of candidates that included women, gays and other minorities and appealed to voters whose goal was to curtail Mr. Erdogan’s powers.
“I voted for H.D.P. because it’s the only party that can break up Erdogan’s bid for absolute power,” said Selen Olcay, 47, a fitness instructor who voted in Istanbul’s Sariyer District. “In this election a lot of Turks abandoned their ideological preferences and voted strategically to derail Erdogan’s one-man rule.”
The Kurdish party opted to run a unified slate, rather than field independent candidates as it had in the past. But it was a big risk: either it would reach the 10 percent threshold and enter Parliament, or it would be shut out, and its seats would have gone to the A.K.P.
In the city of Diyarbakir, in the Kurdish heartland in the southeast, celebrations broke out as people flooded the streets, dancing and setting off fireworks.
In Istanbul, Kurds saw the election as the culmination of decades of struggle, some of it waged violently by the Kurdistan Workers’ Party, or P.K.K., which has fought an insurgency from a base in northern Iraq for more political rights. In recent years Mr. Erdogan’s government had entered peace talks with the Kurds and violence ebbed, and Sunday’s vote raised hopes for a final deal.
“This is the victory of peace against war,” said Sirri Sureyya Onder, an H.D.P. official, speaking to a group of reporters after preliminary results were published.
The Republican People’s Party, the main secular opposition party, came in second with 25 percent of the vote, but it was the Kurds whose surge positioned them as kingmakers in the next Parliament. It also highlighted the evolution of the Kurdish movement, from the battlefields of the southeast, where a bloody insurgency raged for nearly 30 years, to the halls of power in Ankara, the capital.
Even as days of political bargaining lie ahead, the elections capped a two-year period of seismic shifts in Turkish politics. Widespread antigovernment protests in 2013, set off by plans to raze an Istanbul park and replace it with a mall, laid bare the growing resentments among liberal and secular Turks toward the governing party. Then, a corruption scandal threatened to engulf Mr. Erdogan and his government. Mr. Erdogan survived by targeting the followers of his erstwhile ally, the Muslim cleric Fethullah Gulen, who over the years had taken positions in the judiciary and the police and were accused of orchestrating a graft inquiry.
Turkey has felt strains in other arenas. It has taken in nearly two million Syrians, who have been a burden on services and exacerbated tensions in border regions, especially as the economy has slowed. In the wake of the Arab Spring, Turkey pursued an Islamist agenda in the region, supporting the Muslim Brotherhood in Egypt, whose president was deposed by the military. Its policy in Syria of pushing for the ouster of President Bashar al-Assad has been unpopular in Turkey, and Mr. Assad, four years later, is still in power.
The diminished power of Mr. Erdogan’s party is likely to rein in Turkey’s ambitions to shape events in the Middle East, an activist foreign policy that has been controversial among political opponents and the public.
“Turkey’s foreign policy will be less driven by the A.K.P.’s ambitions, which is basically driven by a foreign policy vision to make Turkey a regional player at any cost,” Mr. Cagaptay said, suggesting it had supported various Syrian factions opposing the Assad government and sometimes turned a blind eye to fighters crossing into Syria to join the Islamic State.
He added: “The outcome of the election will take Turkey’s anti-Assad policy down a notch. The government will not be able to drive its agenda single-handedly anymore.”
Turkey, a member of NATO, has seen its relations with its Western allies deteriorate, mainly over Syria and the fight against the Islamic State, the militant group that controls vast areas of Iraq and Syria. An American-led coalition has been carrying out an air campaign against the group, also known as ISIS or ISIL, for nearly a year, but Western officials complain that Turkey has not done enough, such as allowing its air bases to be used for bombing runs. Critics also partly blame Turkey for the rise of the Islamic State for its early support of Islamist groups in Syria.
The election was defined by bitter partisanship, with opponents criticizing Mr. Erdogan for his accumulation of powers, his bashing of the news media and his lavish new official residence, which Mr. Erdogan justified by saying his previous residence was infested with cockroaches. The campaign was also marred by violence, including a bombing last week at a Kurdish political rally that left two people dead.
“Erdogan’s salvos over the past week show how nervous he is about the outcome of this election,” said Ugur Kaplan, 24, a student who voted in Istanbul.
“The A.K.P. has lost votes, and it’s because of him. People are tired of having their lives dictated by one nutty man. It’s time for change.”
Sebnem Arsu contributed reporting.