Yasin Akgul, AFP | Although Erdogan was not running for office Sunday, he became the face of the ruling party's campaign.

President Recep Tayyip Erdogan's conservative party has lost control of Turkey’s biggest city, final tallies showed on Tuesday, sanctioning one of its most serious electoral setbacks in years.

Advertising Read more

On top of its defeat in the capital Ankara, a ruling party stronghold for decades, the ruling AK Party (AKP) lost a tight race for mayor in Istanbul, according to figures released by Turkish electoral authorities.

The AKP said it would appeal the results in Istanbul, citing voting irregularities.

Sunday's local elections were widely seen as a gauge of support for Erdogan as the nation of 81 million faces a daunting economic recession. They were also a first test for Erdogan – who has been accused of increasingly authoritarian tendencies – since he got widely expanded presidential powers last year.

The swings in Ankara and Istanbul mark a major setback for the Islamist leader who campaigned hard to retain hold of them. The opposition also retained its hold over Izmir, Turkey's third-largest city.

Although Erdogan was not running for office Sunday, he became the face of the campaign, rallying tirelessly for months across Turkey, using hostile rhetoric against opposition parties and portraying the vote as a matter of national survival.

EN NW GRAB Q1 JASPER MORTIMER FROM 13 FOR 14H

The decline in urban support for his conservative, religious-based party came despite the fact that Erdogan wields tight control over the media, which hardly covered the opposition candidates' campaigns.

Behlul Ozkan, an associate professor at Marmara University, said Erdogan's loss of ground in Ankara and Istanbul indicated that his socially conservative and construction-driven policies no longer resonated in Turkey's cities.

"Political Islam's quarter-century old hegemony in Turkey's two largest cities is over," he said. "The basic problem is that Erdogan is not able to get votes from middle-income earners, who believe that the economy, education and urban administration are not run well."

Razor-thin win

More than 57 million voters were eligible to choose leaders for 30 major cities, 51 provincial capitals and 922 districts in Turkey, as well as thousands of local positions. The election was marred by sporadic violence, with five dead and scores injured across Turkey.

Erdogan's party and its nationalist allies garnered some 52 percent of the vote overall but the opposition made momentous inroads.

A strategic decision by a pro-Kurdish party to sit out critical races in major cities contributed to the opposition's gains. The opposition also increased its support along the Mediterranean, taking the city of Adana from the nationalists and the resort destination of Antalya from the ruling party.

Erdogan acknowledged setbacks in a speech to his supporters, saying his party would work to understand what had gone wrong and fix the problem.

Unofficial results reported by the state-run Anadolu news agency after all votes were counted showed a razor-thin win for the opposition in the race for mayor of Istanbul, Turkey's largest city and commercial hub. The opposition vote was at 48.8 percent support to the ruling party's 48.5 percent support.

Ekrem Imamoglu, the opposition candidate in an alliance led by the secular Republican People's Party (or CHP), declared that he won Istanbul but his rival, former Prime Minister Binali Yildirim of the ruling party, said his party would file an objection.

Both Ankara and Istanbul have been held by Erdogan's Justice and Development Party, the AKP, and its Islamic-oriented predecessor for 25 years. Erdogan's own ascent to power began as Istanbul mayor in 1994.

Sunday's election was a significant victory for the opposition, which displayed good strategies and promising candidates, said Ozgur Unluhisarcikli, the Ankara director of the German Marshall Fund.

"This will certainly lead to an emerging new political landscape in Turkey," he said.

In predominantly Kurdish provinces, the Peoples' Democratic Party (or HDP), won back some seats from government-appointed trustees, including the symbolic capital of Diyarbakir, but lost several former strongholds to the ruling party.

The government has replaced 95 elected officials since 2016 for alleged links to outlawed Kurdish militants.

(FRANCE 24 with AP)

Daily newsletterReceive essential international news every morning Subscribe