President Recep Tayyip Erdogan's ruling party is leading in municipal elections that he has depicted as a fight for Turkey's survival, but may lose control of the capital in the vote that is seen as a test of his support amid a sharp economic downturn.
Erdogan's conservative, Islamic-based party gained 46 per cent of the votes in the elections with more than half of the more than 194,000 ballot boxes counted, according to state broadcaster TRT.
The main, secular-oriented opposition party has 30.5 per cent.
However, the opposition is leading in Ankara with 49.5 per cent of the votes, according to TRT, in a setback for Erdogan whose ruling party and its predecessor have held the mayoral seat for 25 years.
Erdogan's party appeared to be still holding Istanbul, the country's commercial hub, although the opposition's candidate narrowed the gap.
The voting was marred by scattered election violence that killed at least four people and injured dozens of others across Turkey. Unofficial final results were expected today.
Economic prosperity provided Erdogan and his party with previous election victories. But the party faces the risk of losing mayoral seats in the elections taking place in 30 large cities, 51 provincial capitals and hundreds of districts as Turkey grapples with a weakened currency, a double-digit inflation rate and soaring food prices.
The high stakes of the local contests were brought into stark display with the deaths of two members of the Islamic-oriented Felicity Party, a small rival of the President's Justice and Development Party.
Felicity's leader, Temel Karamollaoglu, alleged a polling station volunteer and a party observer were shot by a relative of a ruling party candidate.
The killings weren't caused by "simple animosity," but happened when the volunteers tried to enforce the law requiring ballots to be marked in private voting booths instead of out in the open, Karamollaoglu tweeted.
Speaking to reporters after he voted, Erdogan said he was sad about the deaths and didn't want them to become a cause for "a questioning or a judgment between political parties."
Two other people were killed in fighting in the southern city of Gaziantep.
Fights related to local elections in several provinces also produced dozens of injuries, Turkey's official Anadolu news agency reported. At least 21 people were injured in southeastern Diyarbakir province from brawls over the election of neighbourhood administrators, Anadolu said.
The elections were a first test for Erdogan since he won re-election under a new system of government that gave the presidency expanded powers.