The main opposition, the Republican People’s Party, won the Istanbul and Ankara mayoral elections, as well as the municipalities of 36 of Turkey’s 81 provinces.
Turkish President Recep Tayyip Erdogan’s party suffered its worst defeat in more than two decades in power in local elections held this weekend.
With most of the votes counted, Mr Erdogan’s main rival, Ekrem Imamoglu, led by 10 percentage points in the mayoral race in Istanbul.
His Republican People’s Party (CHP) retained Ankara by a resounding margin and gained 15 other mayoral seats in cities nationwide.
The CHP won the municipalities of 36 of Turkey’s 81 provinces, according to the state-run Anadolu Agency, making inroads into many strongholds of Mr Erdogan’s party.
It gained 37% of the votes nationwide, compared to 36% for the president’s party.
Mr Erdogan, 70, acknowledged the electoral setback for him and his AK Party (AKP) in a speech delivered from the balcony of the presidential palace, saying his party had suffered “a loss of altitude” across Turkey.
The people delivered a “message” that his party will “analyse” by engaging in “courageous” self-criticism, he said.
“Unfortunately, nine months after our victory in the 28 May elections, we could not get the result we wanted in the local election test.
“We will correct our mistakes and redress our shortcomings,” he added.
Mr Erdogan and the AKP fared worse than opinion polls predicted due to soaring inflation, dissatisfied Islamist voters and, in Istanbul, Mr Imamoglu’s appeal beyond the CHP’s secular base, analysts said.
“Those who do not understand the nation’s message will eventually lose,” Mr Imamoglu, 53, told thousands of jubilant supporters late on Sunday, with some of them chanting for Mr 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.
Istanbul was seen as the main battleground for the Turkish president – a city of 16 million people where he was born and raised and where he began his political career as mayor in 1994.