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.