People try to catch bags containing tea thrown by Turkish President Recep Tayyip Erdogan during a rally of his Justice and Development Party in Ankara on March 14, ahead of local elections on March 31. (Burhan Ozbilici/AP)

Turkey’s election board announced Monday that it was invalidating the results of Istanbul’s mayoral race, which had dealt President Recep Tayyip Erdogan’s party a stinging defeat. A new election will be held late next month, the board said.

Erdogan’s Justice and Development Party, or AKP, had appealed for the cancellation of the March 31 vote over what it deemed irregularities. The election board ruled Monday that some polling officials overseeing that race were not civil servants, in violation of the law, according to Turkey’s state-run news ­agency.

Results last month showed that an opposition challenger, Ekrem Imamoglu, had narrowly defeated Binali Yildirim, the AKP mayoral candidate, in the Istanbul race. Erdogan’s party also suffered rare losses in local elections in several other cities, including Ankara, Turkey’s capital.

The AKP’s extraordinary appeal to redo the Istanbul election immediately drew criticism that Erdogan and his party were willing to undermine confidence in Turkey’s democracy to serve a narrow goal: retaining control of Turkey’s largest city, along with the financial and patronage networks that have benefited the AKP over decades.

On Saturday, Erdogan, speaking to a group of industrialists and business executives, made clear how he thought the election board should rule.

“I haven’t spoken until today, I have remained quiet. But enough is enough,” he said in televised remarks. “My citizens tell me that this election must be renewed.”

Analysts said the decision to challenge the results was a high-stakes gamble for Erdogan — forcing a replay of a vote that was largely seen as a referendum on his own leadership.  

To begin with, it was not clear that the new vote — if free and fair — would alter the result. Imamoglu and other successful challengers nationwide had benefited from voter dissatisfaction with Turkey’s faltering economy, as well as a rare show of unity by the normally fractured political opposition. And Erdogan’s aggressive effort to invalidate the vote in Istanbul will probably further alienate people, especially young, middle-class voters already frustrated with his leadership style, said Gonul Tol, director of the Center for Turkish Studies at the Middle East Institute in Washington. 

“This is a very risky move. If he loses the elections, the loss is going to be even more difficult to swallow. His image will be shattered.  

“And if he wins, it won’t be a real win,” she added.

The prolonged fight over the Istanbul election had also amplified divisions within the ruling party, between a faction that believed the AKP should concede the race and those who considered the seat critical, whatever the cost. In the weeks since the election, rumors about the possibility of a breakaway party have grown louder.  

There were whispers, too, that Yildirim, the AKP candidate for mayor, was losing interest in the job.  

Speaking for the camp that favored conceding the election, Ahmet Davutoglu, a former prime minister and close ally of Erdogan, criticized the AKP’s economic policies and Turkey’s authoritarian turn under Erdogan in a 15-page statement he released last month. The movement’s future, Davutoglu wrote, “must not be sacrificed to cronyism, increasingly swollen egos and fruitless strife.”

The Istanbul mayoral race and its aftermath had also transformed Imamoglu into a national figure, Tol said. Over the past few months, his soft-spoken manner and outreach across the country’s divides — to conservative Muslims and secular Turks, Kurdish voters and nationalists alike — had contrasted sharply with Erdogan’s fiery stump speeches, in which the president often painted his opponents as supporters of terrorists.

Imamoglu’s inclusive message meant he remained a formidable candidate, Tol said. “After Erdogan’s divisive rhetoric and aggressive approach, people loved how moderate [Imamoglu] is,” she said. 

In a speech Monday after the election board’s decision, Imamoglu continued his outreach, soliciting votes from supporters of the AKP, a nationalist party as well as a pro-Kurdish party.

“They are going to want us to fight,” he said. “But we will persistently embrace each other.”