Turkish President Recep Tayyip Erdogan's ruling party suffered a major upset on Monday after local election results showed it lost the capital Ankara and Istanbul after a decade and half in power.
Losing the country's two major cities would be a stunning defeat for Erdogan, a former Istanbul mayor himself, whose ability to win at the ballot box has been unparalleled in Turkish history.
Erdogan campaigned hard, portraying Sunday's vote for mayors and district councils as a fight for the nation's survival, but the election became a test for his Justice and Development Party (AKP) after Turkey slipped into a recession for the first time in a decade.
The opposition CHP party candidate for Istanbul mayor, Ekrem Imamoglu, was leading by nearly 28,000 votes with most ballot boxes counted, Supreme Election Board (YSK) chairman Sadi Guven said.
Imamoglu won almost 4.16 million votes while the AKP candidate, former premier Binali Yildirim, won 4.13 million.
Both claimed victory in the early hours following a tight race for the country's largest city after results showing them in a dead heat.
"We want to start working as soon as possible to serve people," Imamoglu told reporters on Monday. "We want to cooperate with all institutions of Turkey to quickly meet the needs of Istanbul."
'Dirty politics has lost'
In Ankara, opposition mayoral candidate Mansur Yavas had 50.89 percent of votes ahead of the AKP's Mehmet Ozhaseki on 47.06 percent, Anadolu state agency reported, with 99 percent of ballot boxes counted.
"Ankara has won. The loser in Ankara is Ozhaseki, dirty politics has lost," Yavas told supporters who were waving Turkish flags and setting off fireworks at a celebratory rally.
But in a sign of possible turmoil ahead, AKP officials said they would challenge the alleged invalidation of tens of thousands of votes in both cities.
AKP secretary general Fatoih Sahin said the party will appeal in Ankara, saying the gap between the candidates "will narrow down and I believe it will eventually turn into a positive result for us."
Speaking to supporters in Ankara after Sunday's polls closed, Erdogan had said the election was a victory for the AKP, which along with its coalition partner, the rightwing Nationalist Movement Party, won more than 50 percent of votes overall.
'Istanbul is his heart'
The loss in Istanbul, analysts said, would be especially sensitive for Erdogan, who grew up in the city's working-class Kasimpasa neighbourhood, and liked to tell AKP rank-and-file that victory in the city was like winning all of Turkey.
"Istanbul is his heart, it's really important for him, it is the first place they (AKP) started winning," said Ayse Ayata, political science professor at Middle East Technical University in Ankara.
"They have retained their 51 percent majority in total, which is very important. Had they not, this would lead into a questioning of their legitimacy."
For his supporters, Erdogan remains the strong leader they believe Turkey needs and they tout the country's economic development over the years he and the AKP have been in power.
Rallying his base among more religiously conservative Turks, Erdogan had presented his opponents as enemies of the state, tarnishing them as tied to Kurdish militants of the Kurdistan Workers' Party (PKK) who have fought a decades-long insurgency.
Rights activists and Turkey's Western allies say that democracy has been eroded under Erdogan's leadership, particularly after a failed 2016 coup that led to tens of thousands of people being arrested.
The AKP built its ballot box success on Erdogan's perceived economic prowess, but before the vote, the Turkish lira was sliding again, provoking memories of a 2018 crisis that saw the currency fall 30 percent and badly hurt Turkish households.
How he manages the economy will be key for the party's success before the next presidential and general election in 2023.
Turkey has increasingly come under scrutiny as markets have grown wary of Erdogan's policies. Inflation is in double digits, and foreign currency debt payments are high.
The Turkish leader told supporters on Monday that economic reforms will be a focus. His finance minister has already said economic reforms will be announced next week.
"Most probably he will emphasise guaranteeing a certain level of economic growth until the next general elections," said Emre Erdogan, a professor at Istanbul Bilgi University and no relation to the president.
"Most probably the residents of both metropolitan cities suffered from the economic decline and it has been reflected in the polls."