The opposition candidate for mayor of Istanbul has declared victory in a high-stakes repeat election after his rival backed by Turkey's president conceded defeat.

Ekrem Imamoglu's victory means Turkey's largest city won't be governed by President Recep Tayyip Erdogan's party or its predecessor for the first time in 25 years.

Unofficial returns after most votes from Sunday's repeat election were counted showed Imamoglu had a clear majority. His government-backed opponent, former Prime Minister Binali Yildirim, conceded moments after early returns showed him trailing with 44% of the vote to his opponent's 54%. Yildirim said he hopes Imamoglu will serve the city well.

>> Read more: Erdogan made the local elections all about himself. It backfired | Analysis ■ Turkey holds its breath: Is Erdogan about to lose, again? ■ In Istanbul, Turkey’s anti-Erdogan opposition is becoming a dangerous cult | Opinion

Haaretz Weekly Episode 32 0:00 -- : -- 15 Skip 15 seconds backwards Play audio 15 Skip 15 seconds ahead 1 X Change playback rate from 1 to 1 Mute audio

Polls closed in Istanbul Sunday evening after voters cast ballots in the re-run election after a March 31 vote was voided for procedural irregularities.

Imamoglu sought to repeat his win from 12 weeks earlier to become the city's first mayor in 25 years who is not from President Recep Tayyip Erdogan's party or its Islamist-rooted predecessor.

The other candidate in Sunday's election was former Turkish Prime Minister Yildirim, who received support from Erdogan at campaign rallies. The Turkish leader was mayor of Istanbul, the country's largest city, during the 1990s.

President Recep Tayyip Erdogan's party challenged the March 31 vote, alleging irregularities. The political opposition insists victory was wrongly snatched away from the candidate who had been sworn into office. The election board's decision to cancel the March election polarized Turks, who attended campaign rallies in large numbers.

Imamoglu belongs to the secular Republican People's Party, CHP and won the annulled vote by a narrow margin of just 13,729 votes in a surprise victory over his ruling party rival. The 49-year-old is a former contractor and ex-mayor of the district of Beylikduzu in Istanbul. He served as Istanbul's mayor for just 18 days before his victory was annulled. He is also backed by the nationalist Good Party.

Binali Yildirim, 63, is the candidate for the governing Justice and Development Party, AKP. A former prime minister and transport minister, he resigned as parliament speaker to run in the March 31 local government elections. He's also backed by the AKP ally, the Nationalist Movement Party.

Erdogan has famously said: "Whoever wins Istanbul, wins Turkey" and "Whoever loses Istanbul, loses Turkey." Erdogan's rise to power began as Istanbul's mayor in 1994.

The city of more than 15 million residents is Turkey's largest, straddling both Europe and Asia. It draws millions of tourists each year and is the country's commercial and cultural hub.