Recep Tayyip Erdogan’s political party, stung after losing political control of Istanbul for the first time in a quarter of a century, has demanded a full recount of a Sunday’s close municipal elections on Tuesday, alleging “irregularities” and miscounting in a process the government has overseen and tightly controlled for years.

Erdogan’s Justice and Development Party (AKP) also sought a recount of some districts of Ankara, the capital, which it also lost but by a more substantial margin. The move suggested the AKP would not give up Istanbul without a fight.

Erdogan is a native of the city’s working-class waterfront Kasimpasa district, and has remarked repeatedly that Istanbul is the key to controlling Turkey.

The sprawling city of 15 million is a source of massive real-estate deals and development projects that have been the lifeblood of Erdogan’s national political machine. But the party also wants to show a political base disappointed by the Sunday’s election losses that it is doing everything it can to retain power, even if it ultimately relents.

“At the end of the day it’s the election watchdog that will announce the official results,” says Serkan Demirtas, Ankara bureau chief for Hurriyet Daily News, an English-language newspaper.

In pictures: Turkey launches operation in Syria Show all 9 1 /9 In pictures: Turkey launches operation in Syria In pictures: Turkey launches operation in Syria Turkish tanks driving to the Syrian-Turkish border town of Jarabulus yesterday AFP/Getty In pictures: Turkey launches operation in Syria Turkish-backed gather on the outskirts of Jarabulus, Syria, ahead of an offensive on 24 August 2016 Reuters In pictures: Turkey launches operation in Syria Turkish army tanks make their way towards the Syrian border town of Jarabulus, Syria August 24, 2016 Reuters In pictures: Turkey launches operation in Syria Turkish soldiers return from Syria to Turkey with tanks after a military operation at the Syrian border as part of their offensive against the Islamic State (IS) militant group in Syria, Karkamis district of Gaziantep, Turkey, 25 August 2016 EPA In pictures: Turkey launches operation in Syria Turkish army tanks and Turkey-backed Syrian opposition forces move toward the Syrian border as pictured from Karkamis, Turkey, AP In pictures: Turkey launches operation in Syria Turkish tanks on their way to the Turkish-Syria border during an operation against Isis on 24 August 2016 EPA In pictures: Turkey launches operation in Syria Syrian opposition fighters being transported during preparations to enter Jarabulus in Karkamis, Turkey, on 24 August 2016. EPA In pictures: Turkey launches operation in Syria An air strike hitting Isis-controlled territory near Jarabulus, near the Turkish border, on 24 August 2016. EPA In pictures: Turkey launches operation in Syria A Turkish army tank and an armoured vehicle stationed near the border with Syria. Turkish media reports say Turkish artillery has launched new strikes at Isis targets across the border AP

“They are trying to find ways to appeal over a number of irregularities they are claiming. But they will have to accept the results at some point. The elections were free and there were no big rumours or speculation about fraud.”

Mild-mannered Istanbul mayoral candidate Ekrem Imamoglu, of the secular-nationalist, centre-left People’s Republican Party (CHP), surprised Turkey’s political world by defeating his well-financed AKP rival by 25,000 out of more than 8 million votes cast. CHP made other surprising inroads, though the AKP received the most votes and remain the country’s foremost political organisation.

On Tuesday, Erdogan struck a conciliatory tone: “There is no loser in these elections. The winner is every one of our people who cast their votes, whether they voted for us or not,” he wrote on his Twitter account, referring to victories in 15 metropolitan areas, a tally that excludes Istanbul.

“We will continue to establish bridges of love with our people while being aware of the message given at the ballots.”

Still, AKP supporters have ratcheted up rhetoric alleging cheating and vote fraud in the Istanbul election. Authorities have begun posting billboards across Istanbul featuring Erdogan and AKP mayoral contender Binali Yildirim, a former prime minister and speaker of parliament, thanking Istanbul for its support.

They will have to accept the results at some point. The elections were free and there were no big rumours or speculation about fraud Serkan Demirtas, Ankara bureau chief, Hurriyet Daily News

AKP officials, including Yildirim, allege that the number of invalidated votes exceed the opposition’s margin of victory.

In a constant stream of press appearances, AKP officials allege irregularities, mistakes, discrepancies and wrong entries.

“We have detected rigging and irregularities that violate the legislation and a fair election environment from the start of the voting process,” Senocak said.

AKP spokesman Omer Celik vowed to ”respect the results regardless of the outcome, as it is our people’s choice”.

Many opposition members suspect the Supreme Election Council (YSK) that will weigh the merits of any fraud and allegations, and oversee any recount is packed with AKP loyalists. In the past, it has rejected requests for recounts and ignored allegations of impropriety submitted by opposition parties.

Critics of the government accused the AKP of dishonestly wresting control of the Ankara municipality from front-runner Mansur Yavas in 2014 elections.

Attempting a similar move against Imamoglu in the more high-profile Istanbul race could prompt protests and violence that could further damage Turkey’s relations with the west.

Imamoglu said he trusted the YSK, but was disappointed with the behaviour of the AKP. “This chaos makes me sad,” he told reporters on Tuesday before heading to Ankara to confer with CHP leaders. “If I lost this election, I would congratulate my rival. We are confident because we are right. Political ideology will not rule over logic.”

Though vote tallies have not been officially sanctioned, both Imamoglu and Ankara mayor-elect Yavas, also of the CHP, have changed their Twitter biographies to identify themselves as mayor.