With more than 81 percent of the votes counted, Erdogan's conservative Justice and Development Party (AKP) had received 45.3 percent of the vote, the broadcaster CNN Turk reported early on Monday. Its main rival, the center-left Republican People's Party (CHP) garnered 28.2 percent.
Claiming victory, Erdogan labeled some members of the opposition "traitors" and said the electorate had judged them accordingly.
"You have supported your prime minister, I thank you infinitely," Erdogan told the crowd, speaking from the balcony of his party's Ankara headquarters.
"Democracy has won, free will has won. The people have delivered a proper Ottoman slap to them," he said.
Gap narrows in capital
Despite the apparent gap in polling nationally, the race was said to be closer in the capital Ankara. While the AKP were initially polling at about 45 percent, the CHP was running just behind, at some 43 percent.
The CHP has complained of instances of electoral fraud in some municipalities. There were clashes in rural areas, with eight people reported to have died in violence.
The local polls have become viewed as a referendum on Erdogan's government after it was tainted by a corruption scandal. The premier caused widespread anger among liberals in the run up to the elections when he blocked access to Twitter and You Tube to Turkish Internet users. Erdogan, who has been condemned as increasingly authoritarian, claimed the sites were being used to spread lies against the government.
Turkey's social media networks have been filled with recordings that allegedly show Erdogan talking to his son about hiding large sums of money. The prime minister has described the recordings as fakes created by his political rivals.
rc/crh (AFP, AP, dpa, Reuters)