Recep Tayyip Erdogan's ruling AKP declared victory early Monday 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," said Erdogan, who was not on the ballot in the countrywide polls.

He addressed supporters in a tone that suggested he felt he now had a mandate for strong action against his enemies. "From tomorrow, there may be some who flee," he said.

During the campaign, the vote became an unofficial referendum on the prime minister and his policies, as he faced corruption scandals and security leaks.

With about 98 percent of the votes counted by early Monday morning, Erdogan's Justice and Development Party, better known by its Turkish acronym AKP, was ahead with 45.6 percent, according to state-run TRT television, which said the main opposition group, CHP, trailed with 28 percent of the vote.

The CHP, Erdogan said, must look at itself in the mirror.

"The old Turkey is no longer. The new Turkey is here," he said from a balcony at AKP headquarters. "Today is the victory day of the new Turkey, 77 million united ... as brothers."

Erdogan said during the campaign that the election results would reaffirm his legitimacy after a turbulent election campaign, which has seen his government tighten its grip on the courts, purge thousands of police and block access to Twitter and YouTube as it tried to stem a flow of graft allegations.

"Once the ballot boxes are opened, the rest is only footnotes to history," he said as he voted in Istanbul. "Today it is what the people say that matters rather than what was said in the city squares." Istanbul's Taksim Square was the center of large protests in June.

The races were close in the two biggest cities of Istanbul and Ankara, but the ruling party appeared to have the edge, with AKP supporters honking their car horns from early in the evening.

Two buses of riot police, meanwhile, stood ready in Istanbul's plush Nisantasi neighborhood, one of several districts rocked by anti-government protests last summer.

The AKP set a goal of exceeding its 2009 result of 38.8 percent — an outcome that would likely see Erdogan further assert his authority in a power struggle certain to continue.

Erdogan and his party have dominated Turkish politics over the past decade, a period of great prosperity. The AKP came to power backed by a pious Muslim base looking for greater standing in a country that had for decades favored a secular elite. But party, whose symbol is a lightbulb, has cultivated an identity of pragmatism and competency.

The strong showing could embolden Erdogan to run in what will be the first popular election for the presidency in August. If he won, he would take on a role that has been largely ceremonial, but with the aim of extending its powers.

There would be some risks involved. Erdogan has described audio recordings anonymously posted on the Internet implicating him in corruption as "montage." But he will probably have to reckon with more, similar postings surfacing in the run-up to the presidential race.

He could also choose to run for a fourth term as prime minister in parliamentary elections next year.

Sunday's results are a blow to the CHP.

"It's already clear from his speech this evening that he's basically threatening society," said Gursel Tekin, CHP vice president. "This shows his state of mind isn't to be trusted, and these obvious threats are not something that we can accept."

Wire services