Turkish Prime Minister Tayyip Erdogan declared victory in local polls that had become a referendum on his rule and said he would "enter the lair" of enemies who have accused him of corruption and leaked state secrets. "They will pay for this," he said.

Erdogan spoke from a balcony at his AK Party headquarters to thousands of cheering supporters as early results showed it winning some 44-46 percent of the vote, and the opposition CHP trailing with 23-28 percent.

"The people have delivered a proper Ottoman slap to them," he said of opponents in the election.

Speaking to thousands of supporters in Ankara, he lashed out at "traitors" behind a series of leaked audio recording which have charged that Erdogan and his allies are involved in graft. He said the will be held accountable.

"Democracy has won, free will has won ... We have the democracy that the West yearns for," he told cheering supporters who stood in the cold as he delivered his speech from a balcony in the capital.

Erdogan accuses a U.S.-based Islamic cleric, a former ally, of mounting a smear campaign using a network of followers in the police force to concoct a corruption case against him. In response he has purged the police force of thousands of members.

Last week the crisis reached a new level when a secret top-level security meeting about Syria was taped and posted on YouTube. The cleric, Fethullah Gulen, denies any involvement in the security leak or the corruption investigation.

"This is the wedding day of the new Turkey," Erdogan said. "Today is the victory day of the new Turkey, 77 million united and together as brothers."