The opposition candidate in the controversial replay of Istanbul's mayoral election was headed for a comfortable victory on Sunday, dealing a blow to the ruling party of President Recep Tayyip Erdogan.

Erdogan's candidate, Binali Yildirim, conceded defeat as initial results showed his opponent ahead with 53.69 percent of the vote with more than 95 percent of ballots counted.

"According to the result, as of now my competitor Ekrem Imamoglu is leading the race. I congratulate him and wish him good luck," Yildirim said.

Imamoglu, a little-known district mayor at the start of the year, had portrayed the re-run as a test of Turkish democracy after he was controversially stripped of his first victory in March.

Election authorities annulled that result after Erdogan claimed irregularities in the counting - but that galvanised Imamoglu, who vowed "a battle for democracy" to take back the city of 15 million.

Critics say Erdogan was simply reluctant to give up control of Istanbul, Turkey's economic powerhouse and a crucial source of patronage for Islamic conservatives since he won the mayorship himself a quarter-century ago.

Imamoglu, who represents the secular Republican People's Party, said after voting earlier on Sunday: "Today our people will make the best decision... for the sake of our democracy, for Istanbul and also for the legitimacy of all future elections."