ANKARA, Turkiye (AP) — Turkiye's presidential election will be decided in a runoff, election officials said Monday, after incumbent Recep Tayyip Erdogan pulled ahead of his chief challenger, but fell short of an outright victory that would extend his increasingly authoritarian rule into a third decade.

The May 28 second-round vote will determine whether the strategically located NATO country remains under the president's firm grip or can embark on a more democratic course promised by his main rival, Kemal Kilicdaroglu.

While Erdogan has governed for 20 years, opinion polls had suggested that run could be coming to an end and that a cost-of-living crisis and criticism over the government's response to a devastating February earthquake might redraw the electoral map.

Instead, Erdogan's retreat was still less marked than predicted — and with his alliance retaining its hold on the parliament, he is now in a good position to win in the second round.

The uncertainty drove the main Turkish stock exchange BIST-100 more than 6% lower at the open Monday, prompting a temporary halt in trading. But shares recovered after trading resumed, and the index was 2.5% lower in the afternoon compared to the market close Friday.

Western nations and foreign investors were particularly interested in the outcome because of Erdogan’s unorthodox leadership of the economy and often mercurial but successful efforts to put Turkiye at the center of many major diplomatic negotiations. At a crossroads between East and West, with a coast along the Black Sea and borders with Iran, Iraq and Syria, Turkiye has been a key player on issues including the war in Syria, migration flows to Europe, exports of Ukraine's grain, and NATO's expansion.

Preliminary results showed Erdogan won 49.5% of the vote, while Kilicdaroglu grabbed 44.9%, and the third candidate, Sinan Ogan, received 5.2%, according to Ahmet Yener, the head of Supreme Electoral Board.

The remaining uncounted votes were not enough to tip Erdogan into outright victory, even if they all broke for him, Yener said. In the last presidential election in 2018, Erdogan won in the first round, with more than 52% of the vote.

Even as it became clear a runoff was likely, Erdogan, who has governed Turkiye as either prime minister or president since 2003, painted Sunday's vote as a victory both for himself and the country.

“That the election results have not been finalized doesn’t change the fact that the nation has chosen us,” Erdogan, 69, told supporters in the early hours of Monday.

He said he would respect the nation’s decision.

Kilicdaroglu sounded hopeful, tweeting around the time the runoff was announced: “Don’t lose hope.... We will get up and win this election together.”

Kilicdaroglu, 74, and his party have lost all previous presidential and parliamentary elections since he took leadership in 2010 but increased their votes this time.

Right-wing candidate Ogan has not said whom he would endorse if the elections go to a second round. He is believed to have received support from nationalist electors wanting change after two decades under Erdogan but unconvinced by the Kilicdaroglu-led six party alliance's ability to govern.

The election results showed that the alliance led by Erdogan’s ruling Justice and Development Party looked like it would keep its majority in the 600-seat parliament, although the assembly has lost much of its power after a referendum that gave the presidency additional legislative powers narrowly passed in 2017.

Erdogan’s AKP and its allies secured 321 seats in the National Assembly, while the opposition won 213 and the 66 remaining went to a pro-Kurdish alliance, according to preliminary results.

Howard Eissenstat, an associate professor of Middle East history and politics at St. Lawrence University in New York, said those results would likely give Erdogan an advantage in an eventual runoff because voters would not want a “divided government.”

As in previous years, Erdogan led a highly divisive campaign. He portrayed Kilicdaroglu, who had received the backing of the country’s pro-Kurdish party, of colluding with “terrorists” and of supporting what he called “deviant” LGBTQ rights. In a bid to woo voters hit hard by inflation, he increased wages and pensions and subsidized electricity and gas bills, while showcasing Turkey’s homegrown defense industry and infrastructure projects.

Kilicdaroglu, for his part, campaigned on promises to reverse crackdowns on free speech and other forms of democratic backsliding, as well as to repair an economy battered by high inflation and currency devaluation.

But as the results came in, it appeared those elements didn't shake up the electorate as expected: Turkey’s conservative heartland overwhelmingly voted for the ruling party, with Kilicdaroglu’s main opposition winning most of the coastal provinces in the west and south. The pro-Kurdish Green Left Party, YSP, won the predominantly Kurdish provinces in the southeast.

Results reported by the state-run Anadolu Agency showed Erdogan's party dominating in the earthquake-hit region, winning 10 out of 11 provinces in an area that has traditionally supported the president. That was despite criticism of a slow response by his government to the 7.8-magnitude earthquake that killed more than 50,000 people.

Nearly 89% of eligible voters in Turkiye cast a ballot and over half of overseas voters went to the ballot box. Voter turnout in Turkiye is traditionally strong, despite the government suppressing freedom of expression and assembly over the years and especially since a 2016 coup attempt.

Erdogan blamed the failed coup on followers of a former ally, cleric Fethullah Gulen, and initiated a large-scale crackdown on civil servants with alleged links to Gulen and on pro-Kurdish politicians.

Critics maintain the president’s heavy-handed style is responsible for a painful cost-of-living crisis. The latest official statistics put inflation at about 44%, down from a high of around 86%. The price of vegetables became a campaign issue for the opposition, which used an onion as a symbol.

___

Bilginsoy reported from Istanbul. Associated Press writer Cinar Kiper contributed from Bodrum, Turkoye.