In a historic upset, Turks dealt President Tayyip Erdogan and his party their biggest electoral blow yet in Saturday’s nationwide local vote that reasserted the opposition as a political force and reinforced Istanbul Mayor Ekrem Imamoglu as the president’s chief rival amid raging inflation and the highest borrowing costs since the president swept to power more than two decades ago.

With most of the votes counted, Imamoglu declared victory in the Istanbul mayoral race after leading by 10 percentage points while his Republican People’s Party (CHP) retained Ankara and gained 15 other mayoral seats in cities nationwide.

According to Reuters, it marked the worst defeat for Erdogan and his AK Party (AKP) in their more than two decades in power, and could signal a change in the country’s divided political landscape. Erdogan called the March 31 election outcome a “turning point” in a post-midnight address, and in a rare moment of public humility said the election results were not in line with his expectations, and vowed pledged self-criticism over the election results as he added that he still has 4 more years to fix his mistakes, while predicting that the positive results of the economic plan would become apparent in the second half of the year.

Erdogan and the AKP fared worse than opinion polls predicted due to soaring inflation, dissatisfied Islamist voters and, in Istanbul, Imamoglu’s appeal beyond the CHP’s secular base, analysts said.

“Those who do not understand the nation’s message will eventually lose,” Imamoglu, 53, told thousands of jubilant supporters late on Sunday, some of them chanting for Erdogan to resign.

“Tonight, 16 million Istanbul citizens sent a message to both our rivals and the president,” said the former businessman, who entered politics in 2008 and is now widely touted as a likely presidential challenger.

Erdogan, who in the 1990s was also mayor of his hometown Istanbul, had campaigned hard ahead of the municipal elections, which analysts described as a gauge of both his support and the opposition’s durability.

Addressing crowds gathered at AKP headquarters in Ankara, the capital, Erdogan said his alliance had “lost altitude” across the nation and will take steps to address the message from voters.

“If we made a mistake, we will fix it” in the years ahead, he said. “If we have anything missing, we will complete it.”

Elsewhere in Ankara, thousands more supporters had earlier waved Turkish and party flags for a speech by reelected CHP Mayor Mansur Yavas, who trounced his AKP challenger in another disappointment for Erdogan.

According to 92.92% of ballot boxes opened in Istanbul, Europe’s largest city and the country’s economic engine, Imamoglu had 50.92% support compared with 40.05% for AKP challenger Murat Kurum, a former minister in Erdogan’s national government. Polls had predicted a tight contest in Istanbul and possible CHP losses across the country.

Yet partial official results reported by state-run Anadolu Agency showed AKP and its main ally giving up mayoralties in 19 key municipalities including big cities Bursa and Balikesir in the industrialised northwest, possibly reflecting strains on wage earners.

In an even more shocking result, and a first in 35 years, the CHP led nationwide by almost 1% of the votes the results showed.

AKP was set to win mayor’s seat in 23 cities, down from 39 in 2019. CHP is leading the race in 36 provinces, compared with 21 in the last election.

At stake in Istanbul is control of a city of almost 16 million people with a $6.6 billion annual budget. Social aid payments from municipal budgets are critical to voters hit by Turkey’s cost-of-living crisis. How those funds are allocated are decided at municipal councils, making dominance there is just as important as winning the mayor’s seat.

Mert Arslanalp, assistant professor of political science at Istanbul’s Bogazici University, said it was Erdogan’s “severest election defeat” since coming to national power in 2002.

“Imamoglu demonstrated he could reach across the deep socio-political divisions that define Turkey’s opposition electorate even without their institutional support,” he said. “This makes him the most politically competitive rival to Erdogan’s regime.”

In 2019, Imamoglu had dealt Erdogan a sharp electoral blow when he first won Istanbul, ending 25 years of rule in the city by AKP and its Islamist predecessors, including Erdogan’s own run as its mayor in the 1990s. CHP also won Ankara that year.The president struck back in 2023 by securing reelection and a parliamentary majority with his nationalist allies, despite a years-long cost-of-living crisis.

Analysts said the economic strains, including nearly 70% inflation and a slowdown in growth brought on by an aggressive monetary-tightening regime, moved voters to punish AKP this time.

“The economy was the decisive factor,” said Hakan Akbas, a senior adviser at the Albright Stonebridge Group. “Turkish people  demanded change and Imamoglu is now the default nemesis to President Erdogan.”

Erdogan said ending the second election cycle in less than a year will itself bring a reprive for the economy.

In front of the Istanbul Municipality building, flag-waving supporters said they wanted to see Imamoglu challenge Erdogan for the presidency in the future.

“We are very happy. I love him so much. We would like to see him as president,” said Esra, a housewife.

Then again, Erdogan is not known for willingly parting with power and there is a case to be made that Imamoglu’s days as Erdogan’s challenger may be numbered: even after his second Istanbul victory in a row, Imamoglu has another battle to fight. He is accused of insulting members of the Supreme Election Council, which could result in his being banned from political office.

Rising popular support for the Islamist New Welfare Party, which took an even more hardline stance than Erdogan against Israel over the Gaza conflict, also sapped AKP support. The party took Sanliurfa from an AKP incumbant in the southeast.Imamoglu was reelected despite the collapse of the opposition alliance that failed to topple Erdogan last year.

The main pro-Kurdish party, which backed Imamoglu in 2019, fielded its own candidate under the DEM banner in Istanbul this time. But many Kurds put aside party loyalty and voted for him again, the results suggest.

In the mainly Kurdish southeast, DEM reaffirmed its strength, winning 10 provinces. Following previous elections, the state has replaced pro-Kurdish mayors with state-appointed “trustees” following previous elections over alleged militant ties.

Violence erupted earlier in the day, including one incident in the southeast in clashes by groups armed with guns, sticks and stones, killing one and wounding 11. In another, one neighbourhood official, or “muhtar”, candidate was killed and four people were wounded in a fight, Anadolu reported.

Several others were hurt in other incidents while one person was shot dead and two were wounded overnight ahead of the vote in Bursa, the Demiroren news agency reported.

It was too early to observe a market reaction, but according to former Goldman and IIF strategist Robin Brooks, the market won’t like the election result in Turkey, as it was “hoping for an end to election-related stimulus and a return to orthodoxy. This result sends the opposite signal. Markets will see this as keeping Turkey in perpetual election mode. More pump-priming. More devaluation…”