ANKARA (Reuters) - Turkey’s main opposition candidate in Istanbul’s municipal election said on Friday he remained ahead of his rival after a recount of invalid votes in nearly half of the city’s districts demanded by President Tayyip Erdogan’s AK Party.

FILE PHOTO: Ekrem Imamoglu, main opposition Republican People's Party (CHP) candidate for mayor of Istanbul, embraces his supporter at his election campaign office in Istanbul, Turkey April 1, 2019. REUTERS/Huseyin Aldemir/File Photo

The AKP, hurt by a slowing economy, is reeling from its apparent loss of Istanbul, Turkey’s commercial hub, and the capital Ankara, in Sunday’s local elections.

In power nationally since 2002, the AKP and its Islamist predecessors have dominated Turkey’s two biggest cities for a quarter of a century.

The mayoral candidate of the opposition Republican People’s Party (CHP), Ekrem Imamoglu, said he was 18,742 votes ahead of his AKP rival, ex-prime minister Binali Yildirim, after a recount of invalid votes in 17 of Istanbul’s 39 districts and said that gap would not change much after the recount had ended.

“From what I see, it should end this weekend. It will fall into a 18,000-20,000 range, that’s what all the simulations show. These are very tight numbers,” Imamoglu told Turkey’s Fox TV, adding both parties had been awarded votes in the recount.

The AKP’s Yildirim told reporters on Friday that the margin between him and Imamoglu was falling, adding that the outcome of the recount by the High Election Board (YSK) would be different once all recounts were completed.

The AKP has said there are more than 300,000 invalid votes in Istanbul and just under 110,000 in Ankara.

It was unclear how many districts of Istanbul - a city of 15 million people - would ultimately see recounts. The AKP has requested them in all 39 Istanbul districts and all 25 districts in Ankara, where the secularist CHP has secured an apparently insurmountable lead of nearly 4 percentage points.

Both the AKP and CHP had claimed victory in Istanbul on Sunday night, but the next day they said that Imamoglu held a 25,000 vote lead over Yildirim.

In Ankara, the AKP ruling party said on Friday it had submitted an appeal to recount all votes in the capital after an initial partial recount was “far from meeting our expectations”.

PAINFUL FOR ERDOGAN

Ahead of the elections, the CHP formed an electoral alliance with the Iyi (Good) Party to rival the alliance between the AKP and their nationalist MHP allies. The two alliances nominated joint candidates in some cities, including Ankara and Istanbul.

The losses in Ankara and Istanbul, if confirmed, would be especially painful for Erdogan, who campaigned relentlessly for the local elections. He launched his political career in Istanbul and served as the city’s mayor in the 1990s.

Speaking for the first time since Sunday, Erdogan said his alliance had won the majority of seats in Ankara and Istanbul and warned the opposition that, if they won, they would be unable to run the municipalities as they pleased.

“Where will the decisions on local matters, real estate and budgets go through? Through the council. You can’t go and say ‘I’m the mayor, I’ll form the council as I wish’,” Erdogan told reporters after Friday prayers in Istanbul.

“If a mayor doesn’t have a majority, they can’t form the (municipal) commissions and budgets as they please,” he said, adding that the YSK’s decision on the elections would be final.

The AKP presided over more than a decade of strong economic growth in Turkey but a currency crisis last year saw the lira lose 30 percent of its value, and inflation and unemployment have risen sharply. Critics also accuse Erdogan of becoming more authoritarian, especially after a failed 2016 military coup.

In the Aegean coastal province of Izmir, a CHP stronghold, authorities launched an investigation into the new mayor of the Torbali district, Ismail Uygur, for allegedly insulting Erdogan during a speech. Uygur has denied the accusation.

“The AKP doesn’t know how to lose. Democracy means knowing how to lose,” CHP Deputy Chairman Ozgur Ozel said on Twitter.

Imamoglu criticized the AKP’s repeated appeals for recounts.

“How much longer can we recount? There are recounts in some places now, but is the logic to recount until I lose?”