The MHP, an ultranationalist group that has propped up the ruling party, harbours deep suspicions of foreign powers and takes a hardline stance towards Kurdish militants in Syria, potentially limiting the Turkish president's ability to reach a compromise.
In Ankara, Mansur Yavas - the candidate for both the opposition Republican People's Party or CHP and the nationalist Good Party - had been slightly ahead in some recent opinion polls before the election.
On Tuesday the lira weakened as much as 2 percent against the dollar on concerns about renewed tensions with the United States after it halted delivery to Turkey of equipment related to the F-35 fighter aircraft.
Former Prime Minister Binali Yildirim, the AKP party's candidate for mayor of Istanbul declared victory even though the race is too close to call.
The CHP's Imamoglu, with 48.79% of the votes, has a narrow lead over Yildirim, with 48.51%.
"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. Istanbul has an estimated total population of 15 million.
Dr. A. Kadir Yildirim highlighted that winning mayor seats in Ankara and Istanbul provides some hope for the opposition. Yavas said he is the victim of a smear campaign.
"Ankara has won. The loser in Ankara is Ozhaseki, dirty politics has lost".
Erdogan's election losses appear to be partially rooted in the country's economic downturn.
Twitter’s new "Lights out" option is its true dark mode
If it has hit your devices, we suggest checking the "sound and display" option under the "Settings" menu provided in the app. While this is rolling out to iOS today, Twitter told Engadget that it'll be making its way to Android and the web " soon ".
The results do not affect Erdogan's grip on the presidency nor his control of parliament, where the AKP retains control through an agreement with a smaller nationalist party.
"Those who have attempted to bring our country around its knees damaging our public's unity and togetherness, have been dealt a blowoff", Erdogan said, noting that the celebration had emerged as the victor nationwide by a big margin.
In election-related violence, dozens of people were injured in clashes across Turkey.
Years of economic prosperity supplied Erdogan and his party. It also retained its hold over Izmir, Turkey's third largest city, located on the Aegean Sea. Felicity's pioneer, Temel Karamollaoglu, alleged a polling station volunteer and a party observer were captured with a relative of a party candidate. The counting of 84 ballots is yet to be conducted as both parties had raised objections.
The expert stressed that losing two key cities will influence AKP's use of municipalities for sustaining its patronage networks. Fights linked to elections in many states produced dozens of accidents, Anadolu reported.
"Erdogan has drawn support from his base during the last few elections by promising that political stability would bring economic prosperity".
Over the past two years, the relationship between Erdogan and President Donald Trump is complicated over several factors: the protracted incarceration of American pastor Andrew Brunson and the resulting USA sanctions against Turkey to secure his release; Ankara's continuing frustration over the refusal of the U.S.to extradite religious leader and sworn Erdogan enemy Fethullah Gulen for trial; and the US prosecution and sentencing of Turkish banker Mehmet Haken Atilla for his role in a billion-dollar conspiracy.
Analysts also credited the CHP's Ankara, Adana, Mersin and Hatay victories to usual HDP voters.