Supporters of President Recep Tayyip Erdogan celebrate in Istanbul. Photos / AP
Turkish President Recep Tayyip Erdogan's ruling party led today's mayoral elections but suffered setbacks as the opposition regained hold of the capital Ankara and made significant inroads in other parts of Turkey.
The elections, which the Turkish strongman had depicted as a fight for the country's survival, were largely seen as a test of his support amid a sharp economic downturn.
Erdogan's conservative, Islamic-based Justice and Development Party, or AKP, took nearly 45 per cent of the votes in the elections after 90 per cent of the more than 194,000 ballot boxes were counted, according to state broadcaster TRT.
The secular, main opposition party, the Republican People's Party, or CHP had 30 per cent.
The CHP's mayoral candidate for Ankara, Mansur Yavas, won control of Ankara after 25 years of rule by the AKP and a predecessor party.
The 63-year-old lawyer received more than 50 per cent of the votes, according to TRT.
The CHP and its allies also posted gains elsewhere, increasing the number of city mayoral seats from 14 in the previous local elections in 2014 to 20, according to the preliminary results.
"History is being written in Ankara," said deputy CHP leader Haluk Koc, while thousands of supporters celebrated outside the party's headquarters in the capital.
Former Prime Minister Binali Yildirim, the ruling party's candidate for mayor of Istanbul declared victory even though the race in Turkey's largest city and commercial hub was too close to call.
Yildirim garnered 48.71 per cent of the votes against the opposition candidate Ekrem Imamoglu's 48.65 per cent.
CHP leader Kemal Kilicdaroglu rebuked Yildirim for declaring victory "in haste".
Erdogan attaches great importance to Istanbul where he began his rise to power as its mayor in 1994. He has said at campaign rallies that "whoever wins Istanbul, wins Turkey".
Ankara was considered the main battleground of the race, where a former government environment minister, Mehmet Ozhaseki, ran for mayor under the banner of Erdogan and his nationalist allies. The ruling party accused his opponent Yavas of forgery and tax evasion. Yavas says he is the victim of a smear campaign.
The elections were a first test for Erdogan since he won re-election under a new system of government that gave the presidency expanded powers.
Erdogan campaigned tirelessly for AKP's candidates, framing the municipal elections as a matter of "national survival".
He also portrayed the country's economic woes as attacks by enemies at home and abroad.
"Those who have tried to bring our country on its knees by damaging our people's unity and togetherness, have once again been dealt a blow," Erdogan said, noting that the party had emerged as the winner nationwide by a large margin.
The voting was marred by scattered election violence that killed at least four people and injured dozens of others across Turkey. Unofficial final results were expected later today.
Years of economic prosperity provided Erdogan and his party with previous election victories. But the race for 30 large cities, 51 provincial capitals and hundreds of districts were held as Turkey grapples with a weakened currency, a double-digit inflation rate and soaring food prices.