Istanbul (CNN)Turkey's President Recep Tayyip Erdogan is facing a major political setback after his party lost control of the capital, Ankara, in a keenly fought local elections battle.
Erdogan loses control of Turkish capital in local elections setback
Preliminary results also showed the opposition narrowly ahead of the President's Justice and Development Party (AKP) in Istanbul, the country's largest city.
The results, if confirmed, will be a blow to Erdogan, who has dominated Turkish politics since becoming Prime Minister in 2003.
In Ankara, the opposition People's Republican Party (CHP) won more than 50% of votes while the AKP trailed on around 47%, state news agency Anadolu said. It is the first time in 25 years that the Islamist party has lost its grip on the capital.
In Istanbul, the result was too close to call on Monday. According to Anadolu, CHP received 48.79% of votes, narrowly ahead of the AKP with 48.51%. Turkey's Supreme Election Council said that the results from 84 ballot boxes have not yet been included in the final count as there were objections. Both parties claimed victory in Istanbul, Anadolu reported.
However, AKP's Istanbul mayoral candidate Binali Yildirim said that while opposition candidate Ekrem Imamoglu from the CHP had received 25,000 more votes according to preliminary results, he said that over 300,000 votes were "invalid."
"This is an important detail. There might be mistakes and irregularities, our party detected them," he said, adding that they will accept the results only once announced by the official election council.
Istanbul provincial head Bayram Senocak also insisted that Erdogan's party had won. He added that until now their results had always matched with official results.
"There is irregularities that can easily impact [the] election result," Senocak said, according to Anadolu, adding that the AKP could prove it.
Across the country, the President's AKP party, in alliance with the Nationalist Movement Party (MHP), held 51.63% of the overall vote, while the opposition alliance took 37.55%, according to preliminary results reported by Anadolu.
While Erdogan was not running, he was the face of AKP's campaign and held rallies across Turkey for weeks. He described Sunday's votes for mayors and municipal bodies as a matter of national "survival." According to Anadolu, millions turned out to vote.
The result in Istanbul has particular resonance: Erdogan launched his political career there, serving as mayor in the 1990s. Since then, Erdogan's AKP and its predecessor have consistently won in elections.
Erdogan's party also lost Turkey's third city, the historically secular coastal city of Izmir. There, the CHP is leading with more than half the vote, while the AKP is at least 20 points behind.
The elections were widely seen as a referendum on Erdogan and his party ahead of the results. In a speech on Sunday evening, Erdogan said lessons would be learned.
"People who come up with false promises, go ahead. We will see how they will rule, we will continue on our path God willing -- by taking lessons from our mistakes in this election," he said.
According to Anadolu, Erdogan received a phone call from Russian President Vladimir Putin to congratulate him on the local elections, among other leaders, such as Serbia and Azerbaijan's presidents.
Pakistan's Prime Minister Imran Khan tweeted to say he was "delighted to congratulate friend of Pakistan Recep Tayyip Erdogan on another important victory in the Turkish local elections."
Erdogan transformed the nation since his ascent to power in 2003, implementing policies that encouraged economic growth, and challenging Turkey's secular foundations by bringing Islamic conservatism into to public life.
But after a failed military coup in 2016, tens of thousands of people -- many of them his critics -- were arrested and public institutions gutted. In 2017, he gained sweeping new powers in a narrowly won referendum that was widely condemned as a power grab.
While Turkey remains a democracy, Erdogan has taken on an increasingly autocratic edge.
The private mainstream media is owned by pro-government businesses, while state media has been criticized for giving disproportionate airtime to the AKP and to Erdogan. The President's rallies have dominated the airwaves in recent weeks.
Ahead of the election, there was speculation that the economy would influence how the public voted. A falling Turkish Lira, rising inflation and growing unemployment -- especially amongst the youth -- has increased discontent.
Addressing the increased discontent, Erdogan said the government would "make structural reforms to build a stronger economy against attacks," in his address from Ankara.