ANKARA - Turkey's Tayyip Erdogan suffered a severe setback as his ruling AK Party lost control of the capital Ankara for the first time in a local election and he appeared to concede defeat in the country's largest city, Istanbul.Erdogan, who has dominated Turkish politics since coming to power 16 years ago and ruled his country with an ever tighter grip, campaigned relentlessly for two months ahead of Sunday's vote, which he described as a "matter of survival" for Turkey.But the president's daily rallies and overwhelmingly supportive media coverage failed to win over the country's capital or secure a definitive result in Istanbul, as Turkey's tip toward economic recession weighed heavily on voters.Turkish broadcasters said opposition Republican People's Party (CHP) candidate Mansur Yavas had won a clear victory in Ankara, but the vote count in Istanbul was so tight that both parties declared the narrowest of victories."The people have voted in favor of democracy, they have chosen democracy," opposition leader Kemal Kilicdaroglu said, declaring that his secularist CHP had taken Ankara and Istanbul from the AK Party (AKP) and held its Aegean coastal stronghold of Izmir, Turkey's third largest city,Defeat for Erdogan's Islamist-rooted party in Ankara was a significant blow for the president. Losing Istanbul, where he launched his political career and served as mayor in the 1990s, would be an even greater symbolic shock and a broader sign of dwindling support.The Turkish lira, which swung wildly in the week ahead of the elections echoing last year's currency crisis, slipped again on Monday and was down 1.2 percent at 5.62 against the dollar.State-owned Anadolu Agency said the AKP would appeal in some districts of the capital.In Istanbul, the AKP said former Prime Minister Binali Yildirim defeated his CHP rival Ekrem Imamoglu by a mere 4,000 votes - with both candidates polling more than 4 million votes. Imamoglu said he had a lead of 28,000 with only 2,000 votes uncounted.In a speech to supporters in Ankara, Erdogan appeared to accept AKP defeat in Istanbul, although he maintained that most neighborhoods in the city were held by his party. "Even if our people gave away the mayorship, they gave the districts to the AK Party," he said.The party would appeal results wherever needed, he added."TURNING A PAGE"Erdogan pledged that Turkey would now focus on its troubled economy in the run-up to national elections in 2023. "We have a long period ahead where we will carry out economic reforms without compromising on the rules of the free-market economy," he told reporters.Turkey's most prominent leader since the founder of the Turkish republic Mustafa Kemal Ataturk, Erdogan's support has been based on strong economic growth and backing from a core constituency of pious, conservative Muslim Turks.A consummate campaigner, he has been the country's most popular - although divisive - modern politician, tightening his grip in elections last year that ushered in a powerful executive presidency, approved in a bitter 2017 referendum which alarmed Western allies who fear growing authoritarianism in Turkey.But a currency crisis after last year's election dragged the lira down by 30 percent and tipped the economy into recession in the fourth quarter. With inflation close to 20 percent and unemployment rising, some voters appeared ready to punish the president."Today's elections are as historic as that of 1994," prominent journalist Rusen Cakir tweeted, referring to the year Erdogan was elected mayor of Istanbul. "It is a declaration that a page that was opened 25 years ago is being turned."As authorities again scrambled to shore up the lira over the past week, Erdogan cast the country's economic woes as resulting from attacks by the West, saying Turkey would overcome its troubles and adding he was "the boss" of the economy.However Wolfango Piccoli, co-president of Teneo political risk advisers, said the AKP had lost seven of the country's 12 main cities, even without taking Istanbul into account."It's a bad night for the AK Party," he said. "They have done very poorly in all the economic powerhouses of country. For a party which portrays itself as pro-business, it's a huge issue."Moody's rating agency warned the central bank's use of reserves last week to prop up the lira raises new questions over its independence, while uncertainty over Turkey's policy response to recession raises the risk of further capital flight.In mainly Kurdish southeast Turkey, residents celebrated as the pro-Kurdish opposition Peoples Democratic Party (HDP) won back municipalities that authorities had taken over two years ago, accusing the HDP of terrorist links. The HDP denies links to the outlawed militant Kurdistan Workers' Party."They robbed us of our will and we overturned this," Diyarbakir resident Abdullah Elmas said.