Turkey's local elections on Sunday dealt a significant blow to President Recep Tayyip Erdogan and his ruling Justice and Development (AK) Party, as the main opposition Republican People's Party (CHP) claimed victory in key cities, including Istanbul and Ankara. The setback for the ruling party came just months after Erdogan's narrow re-election as president in a knife-edge May runoff vote against opposition leader Kemal Kilicdaroglu.

Preliminary official results showed the CHP winning 49 out of 81 municipalities, including 14 out of 30 urban areas in the country, according to Turkey's High Electoral Council. With 99.8% of the votes counted, unofficial results indicated that CHP candidate and incumbent mayor Ekrem Imamoglu was re-elected as mayor of Istanbul with 51.1% of the votes, while the CHP's Mansur Yavas secured 60.4% of the vote in the capital, Ankara.

"The period of one-man rule is over today," Imamoglu, a 53-year-old businessman-turned-politician, told cheering crowds in Istanbul on Sunday night. "As we celebrate our victory, we send a resounding message to the world: the decline of democracy ends now. Istanbul stands as a beacon of hope, a testament to the resilience of democratic values in the face of rising authoritarianism."

For Erdogan, the loss of Istanbul, a strategic and personal crown jewel that he was determined to reclaim, was particularly stinging. The city had been run by religiously inclined parties - first by the Welfare Party, of which Erdogan was a member, and then by the AK Party - for 25 years until the CHP's victory under Imamoglu in 2019. The AK Party also lost 10 Istanbul districts to rivals in the latest election, including Beyoglu, the district where Erdogan was born.

Erdogan conceded defeat on behalf of his party, saying he plans to respect the will of the Turkish people. "Unfortunately, we could not get the result we wanted and hoped for in the local election test," he said in a speech delivered Monday at AK Party headquarters in Ankara. "Regardless of the results, the winner of this election is primarily our democracy, the national will, and all 85 million people, regardless of their political views."

Analysts attributed the AK Party's defeat to voters' frustration with both a cost-of-living crisis driven by nearly 70% inflation and Erdogan's divisive political style. The result has cast uncertainty over the president's plans for a new constitution, which could potentially extend his rule beyond 2028 when his term ends.

In response to the election outcome, Erdogan vowed to correct any mistakes that led to his party's defeat. "If we made a mistake, we will fix it," he said, without indicating what changes he might make within his party or in policy.

The CHP's success in the local elections marked a significant shift in Turkey's political landscape, with the party winning the popular vote for the first time in decades and penetrating far into conservative central Turkey. The Islamist New Welfare Party also emerged as a surprise third-place finisher, gaining 6.2% support by taking an even more hardline stance than Erdogan against Israel over the Gaza conflict.

As Turkey grapples with the aftermath of the local elections, the focus will be on how Erdogan and his AK Party respond to the setback and whether the opposition can capitalize on its newfound momentum. The CHP's Imamoglu, now touted as a potential presidential challenger, has emphasized the importance of unity and moving away from polarization in the wake of the election.

"All parties need to move away from polarisation and do something for our country with unity," said Onur Hizmetci, a 42-year-old accountant who had voted for the AK Party for the last 15 years. "People are sick of fighting and arguing."