Istanbul (AFP) - Turkish President Recep Tayyip Erdogan's AKP party appeared so sure of winning Istanbul in Sunday's election that posters of its candidate thanking the city were plastered on walls early Monday.

Instead, Ekrem Imamoglu, a soft-spoken opposition figure, appears to have pulled off a shock win over AKP powerhouse candidate, former premier Binali Yildirim, to end the ruling party's long reign over Turkey's largest city.

Erdogan's AKP suffered a major upset in the Sunday ballot after results showed they had lost not only the capital Ankara and also the country's economic hub Istanbul.

Imamoglu was leading by nearly 28,000 votes with most ballots counted, Supreme Election Board (YSK) chairman Sadi Guven said on Monday.

Imamoglu's rise gives hope to a younger generation of politicians from the Republican People's Party (CHP), Turkey's secular party, as it challenges more than a decade and half of AKP in power.

The quietly spoken, bespectacled CHP candidate took a low-key approach to campaigning, hoping that discretion would be an "advantage" against a popular, well-known AKP figure.

Imamoglu, 49, was often seen around a table discussing local issues with voters and taking selfies with them on their mobile phones.

In contrast, it was Erdogan who dominated scores of large rallies for his loyalist Yildirim in Istanbul, whipping up supporters in televised speeches that filled the airwaves, even though he himself was not running.

"The media, especially the state television is far from being fair... but we have social media which is at least an untouched area for now," Imamoglu told AFP during the campaign.

"Right now my biggest weapon in the field is the thousand-year-old method of communication by word of mouth."

In one campaign visit, Imamoglu toured the touristic spice market in the heart of Istanbul but kept his stoic approach when one citizen -- apparently an AKP voter -- refused to shake his hand.

"Imamoglu is open minded and a man of compromise who is fond of having a common table to discuss problems," his press aide Murat Ongun told AFP.

Story continues

- Football and business -

Born in 1970 in the Black Sea coastal city of Trabzon in northeast Turkey, Imamoglu studied business administration in Istanbul University and later completed a masters degree in management, according to his party website.

He worked in the family construction business before entering into local politics a decade ago. He was elected district mayor of Istanbul's Beylikduzu area in 2014.

He shares one common trait with Erdogan, a love of football. The Turkish leader was a semi-professional player in his youth. Imamoglu was also an amateur footballer and is still involved with local Trabzonspor team.

Imamoglu was well known as a competent mayor of his middle-class Istanbul district and benefited from his non-ideological approach that didn't polarise voters, said Berk Esen, professor at Ankara's Bilkent University.

"If he succeeds in performing well as a mayor, CHP may expand its voter base in Turkey's most populous city and the country, with Imamoglu emerging as a national figure," Esen said.

His campaign slogan touted his pragmatism: "If there is Imamoglu, there is solution".

Throughout election night until the early hours of Monday, Imamoglu kept up a marathon of pressers to inform on the results.

After both candidates early Monday declared victory, he made sure to steer away from provocation. Declaring victory later on Monday, he also took a conciliatory approach.

"We want to start working as soon as possible to serve our people," he said. "We want to cooperate with all institutions of Turkey to rapidly meet Istanbul's needs."

His results may not yet fully official, but Imamoglu on Monday had already changed his title on his official Twitter account to "Mayor of Istanbul Metropolitan Municipality".