Economic prosperity provided Erdogan and his party with previous election victories. The party could lose key posts in the mayoral elections taking place in 30 large cities as Turkey copes with a weakened currency, a double-digit inflation rate and soaring food prices.
The high stakes of the local contests were brought into stark relief 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 alleged.
Speaking to reporters after he voted, Erdogan said he was sad about the deaths and did not want them to become a cause for "a questioning or a judgment between political parties."
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 neighborhood administrators, Anadolu said.
The exact causes of the fights remained unclear. Election campaigning was highly polarized, with Erdogan and other officials using hostile rhetoric toward opposition candidates.
Sunday's elections were a first test for Erdogan since he won re-election under a new system of government that gave the presidency expanded powers.
Erdogan's ruling party has renewed an alliance with the country's nationalist party to increase votes. Opposition parties also coordinated strategies and put forward candidates under alliances in an effort to maximize the chances of unseating members of the Justice and Development Party, known in Turkish by the acronym AKP.
A main battleground appears to be the capital, Ankara. Opinion polls suggested the candidate of the opposition alliance, Mansur Yavas, could end the 25-year rule of AKP and its predecessor.
Another closely watched mayoral election is in Istanbul, Turkey's largest city. Erdogan began his rise to power as its mayor in 1994 and said at campaign rallies that "whoever wins Istanbul, wins Turkey."
Erdogan named former Prime Minister Binali Yildirim to run against opposition candidate Ekrem Imamoglu in the Istanbul mayor's race.
Before the elections, Erdogan campaigned tirelessly for AKP's candidates, framing the municipal elections taking place across Turkey as matters of "national survival." He also portrayed the country's economic woes as attacks by enemies at home and abroad.
Gonul Ay, 38, said she voted for the ruling party and Yildirim in Istanbul because of his experience.
"I voted for the AKP for continuity and so that their services continue," the homemaker said. "God willing, this crisis and chaos will be fixed and we'll see healthier, happier days."
Volkan Duzgun, 32, said he voted for opposition candidate Imamoglu.
"All elections have turned into a race against the one-man regime, and people we call the opposition is trying to carve out some breathing space," Duzgun said.
Erdogan's party has threatened to not accept election results in southeast Turkey if pro-Kurdish Peoples' Democratic Party candidates with alleged "terror" links win.
Since 2016, Erdogan's government has replaced elected mayors from the pro-Kurdish party in nearly 100 municipalities, installing in their place government-appointed trustees and alleging the ousted officials had links to outlawed Kurdish militants.
The pro-Kurdish party is seeking to win back the offices. However, it strategically sat out critical mayoral races in major cities, including Istanbul and Ankara, with the aim of sending votes to a rival secular opposition party to help challenge Erdogan's party.
Since the previous local elections in 2014, Turkish citizens have gone to the polls in five different elections. In last year's presidential and parliamentary elections, Erdogan garnered 52.6 percent of the votes and his party and its nationalist ally won 53.7 percent of the parliamentary vote.
Fraser reported from Ankara, Turkey.