ANKARA (Reuters) - Turkey’s main opposition candidate in Istanbul urged the High Election Board (YSK) on Wednesday to confirm him as the elected mayor after it ruled in favour of a partial recount of votes in 18 of the city’s 39 districts.

Initial results from Sunday’s mayoral elections showed the opposition Republican People’s Party (CHP) had narrowly won control of Turkey’s two biggest cities, Istanbul and Ankara, in a shock upset for President Tayyip Erdogan’s ruling AK Party.

If those results are confirmed in the coming days, the CHP will gain control of municipal budgets with an estimated total value of 32.6 billion liras ($5.79 billion) for 2019 in Istanbul, Turkey’s commercial hub, and the capital Ankara.

Erdogan - who campaigned hard for the AKP ahead of the vote - would likely lose some oversight for local contracts in the two cities, possibly complicating his efforts to drag the Turkish economy out of recession.

However the AKP submitted objections to election results in all districts of Istanbul and Ankara, saying the results had been impacted by invalid votes and voting irregularities.

In Istanbul, CHP candidate Ekrem Imamoglu, and his AKP rival, ex-prime minister Binali Yildirim, both said on Monday that Imamoglu was about 25,000 votes ahead, a relatively slim margin in a city of some 15 million people.

The chairman of the Election Board (YSK), Sadi Guven, said on Wednesday it had ruled that the recount of what had been marked as invalid votes should go ahead in eight Istanbul districts, some of them AKP strongholds, but added that appeals were still underway.

The state-run Anadolu news agency later said the YSK decided to recount invalid votes in 15 districts and all votes in three other districts as a result of the appeals. The AKP had said previously there were more than 300,000 invalid votes.

Six of the 18 districts being recounted were initially won by the CHP, one by the nationalist MHP, and the rest by the AKP, according to Anadolu.

Imamoglu called on the YSK to “do its job” and name him mayor, accusing the AKP of disrespecting the people of Istanbul.

“We want justice. We demand our mandate from the YSK, which has given the numbers, as the elected mayor of this city... The world is watching us,” he told reporters.

After Imamoglu spoke, the hashtag #MazbatamiziVerin (Give our Mandate) was the top trending topic on Twitter in Turkey.

AKP Deputy Chairman Ali Ihsan Yavuz said his party was not doing anything illegal and added that the vote difference between Imamoglu and Yildirim had fallen to below 20,000 votes.

Slideshow ( 3 images )

“We believe the reality will emerge tonight and we will all accept the results,” Yavuz told reporters.

LOCAL PURSE STRINGS

Pro-government newspapers on Wednesday said there had been a conspiracy against Turkey in the local elections, with the Star newspaper likening this to an attempted military coup in 2016 and nationwide protests in 2013.

Slideshow ( 3 images )

Yeni Safak newspaper editor Ibrahim Karagul called for a second vote after what he termed a “coup via elections”, adding without providing evidence that supporters of the U.S.-based Muslim cleric Fethullah Gulen - blamed by Ankara for the 2016 coup attempt - were involved.

In Ankara, opposition candidate Mansur Yavas received 50.9 percent of votes on Sunday, nearly 4 percentage points ahead of his AKP rival. Recounts were planned in 11 Ankara districts due to AKP appeals, Anadolu said.

In some 100 rallies during his election campaign, Erdogan had described the opposition alliance as terrorist supporters linked to Gulen’s network and Kurdish militants.

Erdogan’s political success has rested on years of stellar economic growth in Turkey, but a recession that has brought surging inflation and unemployment and a plunging lira have taken their toll on the president’s popularity.

While Erdogan’s ruling alliance won a nationwide majority of just under 52 percent of all votes, losing Ankara and Istanbul - where he started his political life - would significantly dent his dominance.

“It is by controlling the municipality that you keep your support happy because it is at the municipal level that you give away lots of things to your core base,” said Wolfango Piccoli, co-president of Teneo political risk advisers.

While official results have not yet been announced, Erdogan has said his alliance had won the majority of municipal councils across Istanbul and Ankara. The AKP has said this was a sign of irregularity in the vote count.

Uncertainty generated by the local elections has added to volatility in the Turkish lira, which sold off sharply nearly two weeks ago, reflecting waning confidence among both Turks and international investors.

The lira was flat on Wednesday but slipped 2 percent on Tuesday after relations with Washington soured following a U.S. decision to halt delivery to Turkey of equipment related to the F-35 fighter aircraft.

Adding to investor concerns over fraying diplomatic ties and possible U.S. sanctions over the F-35 aircraft and missile defence, the U.S. State Department urged Ankara to respect the “legitimate election results.”

Ankara responded by warning against foreign interference and “any steps that may be construed as meddling in Turkey’s internal affairs.”