Ekrem Imamoglu, the candidate of the secular opposition Republican People's Party, CHP, talks to supporters from atop his campaign bus during a celebratory rally in Istanbul, late Sunday, June 23, 2019. The opposition candidate for mayor of Istanbul celebrated a landmark win Sunday in a closely watched repeat election that ended weeks of political tension and broke the long hold President Recep Tayyip Erdogan's party had leading Turkey's largest city. (Onur Gunay/Imamoglu Media team via AP)

ISTANBUL (AP) — Voters in Istanbul delivered a stunning victory to Turkey's secular opposition in a repeat election for mayor Sunday. The opposition candidate, Ekrem Imamoglu, finished way ahead, breaking the grip of President Recep Tayyip Erdogan's party on Turkey's most important city. Here's a look at what happened and the options facing Istanbul's next mayor:

THE VOTE

The Republican People's Party's Imamoglu won with 54.21% of the vote, beating the ruling Justice and Development Party's Binali Yildirim by more than 806,000 votes. Yildirim swiftly conceded Sunday night, congratulating his opponent.

The mayor-elect's margin of victory dwarfed the 13,729 votes that separated the two candidates in the March 31 election Imamoglu also won. After that vote, both Yildirim and Imamoglu initially claimed victory. Erdogan's ruling party, also known by the acronym AKP, filed a series of objections with Turkey's election authorities, leading to weeks of partial recounts.

The electoral board annulled the election after Imamoglu served 18 days in office and ordered the election rerun held Sunday.

Political analysts credited the surge in Imamoglu's support to his intense campaigning and a sense of injustice many voters felt after the March result was thrown out. Nearly 10.6 million voters were eligible to cast ballots Sunday, and turnout reached almost 85%.

Istanbul, along with the Turkish capital of Ankara, will both have mayors from the secular opposition party after being led for 25 years by the Islamic-leaning ruling party and its predecessor.

WHAT'S NEXT?

Imamoglu has promised to get to work for the city of more than 15 million residents, hoping to draw a line under months of political tension from the disputed mayoral election.

Istanbul is the cultural and commercial heart of Turkey, accounting for nearly a third of its GDP. The local government had a budget of $8.8 billion last year to run the city.

The new mayor said he would lift up the quarter of Istanbul's population that lives in poverty, increase green spaces and end what he has described as the governing party's "squandering" of public funds.

He alleges Erdogan's party, the AKP, used Istanbul's resources to award lucrative contracts to businesses close to the government and enrich themselves. The party denies the claim and says its aimed at undermining its record of delivering high growth and modern infrastructure.

But Imamoglu will need the support of district mayors and municipal assembly members to win approval of his projects and budget. Istanbul is a sprawling city, straddling Europe and Asia, with 39 districts. Each has its own mayor overseeing tasks that fall outside the metropolitan mayor's duties.

AKP controls 25 of Istanbul's 39 districts and a majority in the municipal assembly.

"The AKP now has two choices. One is, of course, working together with Imamoglu, taking advantage of the fact that (he) has publicly announced that he would like to work together with President Erdogan," said Ozgur Unluhisarcikli, Ankara office director of the German Marshall Fund.

The second option, Unluhisarcikli said, could be to undermine Imamoglu. With changes to local administration laws, Erdogan could "hollow out the powers of metropolitan mayors" by transferring some of the mayor's powers to district mayors or to the capital, Ankara.

RISKS TO POWER

Erdogan congratulated Imamoglu in a tweet but previously said on multiple occasions that a mayor from Turkey's political opposition would not be able to effectively run Istanbul with AKP controlling so many districts. The Turkish leader last week downplayed the importance of the mayor's office position, even though his own political career began as Istanbul mayor in 1994.

Erdogan has also hinted that a judicial process could be launched against Imamoglu for allegedly insulting the governor of northern Ordu province. Imamoglu denies calling the governor a "dog."

The Turkish government has a track record of seizing control of municipalities in the country's predominantly Kurdish southeast. After a failed July 2016 coup, the government appointed trustees to replace 95 local elected officials, alleging they had links to an outlawed Kurdish militant group.

The pro-Kurdish party regained many of those seats in March local elections. But the party says 68 officials were prevented from taking office in six municipalities and assemblies on the grounds they had been dismissed from public service under emergency decrees resulting from the failed coup.

Both Yildirim, in his concession speech, and Erdogan, in his tweets, said Sunday's results showed Turkish democracy and the "national will" at work in Istanbul.

In his victory speech to tens of thousands of supporters late Sunday, Imamoglu thanked Yildirim and Erdogan for congratulating him. He expressed hope for cross-party cooperation in Istanbul

"I am ready and willing to work with you," he said.

___

Follow Bilginsoy at http://twitter.com/zbilginsoy

Ekrem Imamoglu, candidate of Turkey's secular opposition Republican People's Party, makes a statement after his election victory, in Istanbul, Sunday, June 23, 2019. Turkish President Recep Tayyip Erdogan has congratulated Imamoglu who won a repeat mayoral election in Istanbul and defeated Erdogan's candidate for the second time. (AP Photo/Burhan Ozbilici)
Ekrem Imamoglu, candidate of the secular opposition Republican People's Party, or CHP, releases the line to start a boat ride in the Bosphorus Strait, following his last election rally in Istanbul, Saturday, June 22, 2019, ahead of June 23 re-run of Istanbul elections.The 49-year-old candidate won the March 31 local elections with a slim majority, but Turkey's electoral authority annulled the result of the vote and ordered the new election. (AP Photo/Lefteris Pitarakis)
Ekrem Imamoglu, candidate of the secular opposition Republican People's Party, or CHP waves to the media at a polling station in Istanbul, Sunday, June 23, 2019. Voters in Istanbul returned to the polls Sunday for a re-run mayoral election ordered up by authorities after President Recep Tayyip Erdogan and his political allies lost control of Turkey's largest city for the first time in 25 years. (AP Photo/Lefteris Pitarakis)
Supporters of Ekrem Imamoglu, the candidate of the secular opposition Republican People's Party, CHP, celebrate in central Istanbul, Sunday, June 23, 2019. In a blow to Turkish President Recep Tayyip Erdogan, Imamoglu declared victory in the Istanbul mayor's race for a second time Sunday after Binali Yildirim, the government-backed candidate conceded defeat in a high-stakes repeat election. (AP Photo/Lefteris Pitarakis)
Turkey's President Recep Tayyip Erdogan casts his ballot at a polling station in Istanbul, Sunday, June 23, 2019. Polls have opened in a repeat election in Turkey's largest city where Erdogan and his political allies could lose control of Istanbul's administration for the first time in 25 years. (AP Photo/Emrah Gurel)
Supporters of Ekrem Imamoglu, the candidate of the secular opposition Republican People's Party, CHP, light up a flare as they celebrate in central Istanbul, Sunday, June 23, 2019. In a blow to Turkish President Recep Tayyip Erdogan, Imamoglu declared victory in the Istanbul mayor's race for a second time Sunday after Binali Yildirim, the government-backed candidate conceded defeat in a high-stakes repeat election. (AP Photo/Lefteris Pitarakis)
Ekrem Imamoglu, the candidate of the secular opposition Republican People's Party, CHP, waves to supporters at a celebratory rally in Istanbul, late Sunday, June 23, 2019. Tens of thousands of people attended an election night celebration after a repeated vote in Istanbul made Imamoglu the mayor-elect of Turkey's largest city. (Onur Gunay/Imamoglu Media team via AP)
Ekrem Imamoglu, right, candidate of the secular opposition Republican People's Party, or CHP, and his wife Dilek pose for the photographers at a polling station in Istanbul, Sunday, June 23, 2019. Voters in Istanbul returned to the polls Sunday for a re-run mayoral election ordered up by authorities after President Recep Tayyip Erdogan and his political allies lost control of Turkey's largest city for the first time in 25 years. (AP Photo/Burhan Ozbilici)
Ekrem Imamoglu, candidate of the secular opposition Republican People's Party, or CHP makes statements outside a polling station in Istanbul, Sunday, June 23, 2019. Voters in Istanbul returned to the polls Sunday for a re-run mayoral election ordered up by authorities after President Recep Tayyip Erdogan and his political allies lost control of Turkey's largest city for the first time in 25 years. (AP Photo/Lefteris Pitarakis)
Ekrem Imamoglu, candidate of Turkey's secular opposition Republican People's Party, makes a statement after his election victory, in Istanbul, Sunday, June 23, 2019. Turkish President Recep Tayyip Erdogan has congratulated Imamoglu who won a repeat mayoral election in Istanbul and defeated Erdogan's candidate for the second time. (AP Photo/Burhan Ozbilici)
Ekrem Imamoglu, candidate of the secular opposition Republican People's Party, or CHP waves to their supporters outside a polling station in Istanbul, Sunday, June 23, 2019. Voters in Istanbul returned to the polls Sunday for a re-run mayoral election ordered up by authorities after President Recep Tayyip Erdogan and his political allies lost control of Turkey's largest city for the first time in 25 years. (AP Photo/Lefteris Pitarakis)
Ekrem Imamoglu, candidate of the secular opposition Republican People's Party, or CHP thanks his supporters outside a polling station in Istanbul, Sunday, June 23, 2019. Voters in Istanbul returned to the polls Sunday for a re-run mayoral election ordered up by authorities after President Recep Tayyip Erdogan and his political allies lost control of Turkey's largest city for the first time in 25 years. (AP Photo/Burhan Ozbilici)
Supporters of Ekrem Imamoglu candidate of the secular opposition Republican People's Party celebrate in Istanbul, Sunday, June 23, 2019. In a blow to Turkish President Recep Tayyip Erdogan, an opposition candidate declared victory in the Istanbul mayor's race for a second time Sunday after the government-backed candidate conceded defeat in a high-stakes repeat election. (AP Photo/Emrah Gurel)