The results would be a major upset for the ruling party, which has been in power for a decade and a half.
In Istanbul, Imamoglu was on 4,159,650 votes, with the Justice and Development Party (AKP) candidate and former premier Binali Yildirim on 4,131,761.
Both candidates had claimed victory in the early hours of Monday following a tightly contested race for the country's largest city and economic hub and with preliminary results showing them in a dead heat.
Procedures to challenge the vote continue, Guven said with 84 ballot boxes left to the counted.
Erdogan campaigned hard portraying the vote for mayors and district councils as a fight for the nation's survival, but the election became a test of AKP's support after an economic slowdown hit Turkey.
With 99 percent of the ballot boxes counted early on Monday, opposition candidate for Ankara mayor, Mansur Yavas was ahead with nearly 51 percent of votes and the AKP on 47 percent, Anadolu state agency reported.
Erdogan, whose ability to win repeatedly at the polls is unparalleled in Turkish history, appeared more vulnerable with the economy in recession for the first time in a decade, unemployment higher and inflation in double digits.