Istanbul, Turkey (CNN) The main Turkish opposition party has won the rerun of Istanbul's mayoral election, according to Turkey's Anadolu News Agency, in a blow to President Recep Tayyip Erdogan.

With more than 99% of the votes counted, Republican People's Party (CHP) candidate Ekrem Imamoglu was in the lead with about 54% of the vote, state news agency Anadolu reported on Sunday.

Imamoglu said "the whole Turkey won the election, not a group or party."

"You stood up for the democracy tradition of more than one hundred years. Thank you Istanbul," he added.

Official results were expected early Monday, according to the Turkish election board.