Turkey's ruling party has claimed victory in critical local elections that took place amid corruption allegations, damaging security leaks and social media bans that have shaken Prime Minister Recep Tayyip Erdogan's government

Addressing his supporters late on Sunday after the results were revealed, Erdogan said he would "enter the lair" of his enemies and make them "pay the price" for plotting his downfall. "Those who attacked Turkey got disappointed," he said.

The elections were widely seen as a vote of confidence for the rule of Erdogan, and his supporters celebrated the victory throughout the night.

Erdogan's Justice and Development Party (AKP) got 45.6 percent of the votes as the main opposition Republican People's Party (CHP) scored 27.9 percent and the Nationalist Movement Party (MHP) held 15.2 percent as 98 percent of the votes were counted at Monday noon, semi-official Anatolia news agency said.

According to the agency, in Istanbul, Turkey's largest city and financial capital, the AKP held 48 percent of the votes, while the CHP got 39 percent.

The AKP also won the capital Ankara with 44.7 percent of the votes followed by the CHP with 43.8 percent.

In the Aegean province of Izmir, the country's third largest city, the CHP scored a comfortable win with 49.5 percent as AKP got 35.9 percent of the votes.

Over 99 percent of the votes were counted in all three cities.

Particularly, Ankara's results were a source of confusion throughout the night and the morning as CHP's Mansur Yavas and the AKP's Melih Gokcek, the current mayor, both declared victories multiple times. CHP said on Monday that it would appeal against the election results in Ankara.

Both the CHP and AKP blamed various media outlets with manipulation on results and called on their members not to leave ballot boxes they had been monitoring.

'AKP delivers its promises'

The AKP, which has ruled the country since 2002, came to power amid a major financial crisis and an environment of corruption. It received 38.8 percent of the votes in the last local elections in 2009 and 49.9 of the votes in the parliamentary elections in 2011.

There are no other parties apart from AKP and no leader apart from Erdogan that can get this country out of its difficulties. Mustafa Hayir, AKP supporter

Erdogan established the AKP in 2001 with a wide-range support attracting centre-right voters, religious conservatives and some of the pro-democratisation liberals.

He lost the support of the Turkish liberal scene for the most part in the last couple of years.

"I have voted for the AKP because it actually works and delivers services. The government’s services are important for me. AKP delivers what they promise," Bedri Ucar, a 32-year-old receptionist from central Istanbul, told Al Jazeera.

"There are no other parties apart from the AKP and no leader apart from Erdogan that can get this country out of its difficulties. For me the most important thing is existence and integrity of the state," said Mustafa Hayir, a 35-year-old supermarket employee from the conservative Istanbul neighbourhood of Yeni Sahra.

Ayberk Tekcan, a 38-year-old driving instructor from Maltepe on Istanbul's Asian side, believed the ruling party acts in line with its own interests, not Turkish citizens'. "Erdogan is a corrupted politician using religion as a tool. Therefore, I voted for the CHP. The AKP won the elections by fraud. I want a government that does not abuse my country," he told Al Jazeera.

Selin Sahin, a veterinary from the predominantly secular Istanbul district of Kadikoy, said she voted for the CHP just to stand against the AKP.

"It is really dire that the AKP did not lose votes despite all this happening, particularly the corruption allegations and online bans. Many people see Erdogan like a prophet. We have a serious problem in Turkey and I am not hopeful. Erdogan is going to tighten his dictatorship."

The CHP portrays Erdogan as a corrupt "dictator" clinging to power, but not struggling for the country's welfare.

Online leaks

The prime minister frequently accuses his opponents of being "traitors" because of tens of anonymous Internet postings of recorded conversations that allegedly document corrupted actions of him, his family members and his aides. Erdogan denies the claims.

The tensions in the country increased further in recent days by the leaking of a recording of a top-level security meeting.

In the recording confirmed by the government, the intelligence chief, foreign minister and military commanders discuss a possible armed intervention in Syria. The Turkish intelligence chief, Hakan Fidan, talks about staging a fake attack on Turkish soil from Syrian soil in order to start an operation on Syria.

Following the launch of corruption investigations and raids in December targeting businessmen with links to the government and sons of ministers, Erdogan has reshuffled thousands of employees from the Turkish judiciary and police.

The prime minister said that those behind the investigations were trying to form a "state within a state" or "parallel state", blaming the movement of Fethullah Gulen, a United States-based Turkish cleric, whose followers are apparently highly influential in Turkey's police forces and judiciary.

According to Nihal Bengisu Karaca, a conservative columnist for national Haber Turk newspaper, the government has faced illegal alliances trying to undermine its power that have no place in democratic politics.

She told Al Jazeera: "Although claims that would normally shake a government have been revealed through illegal recordings, the Turkish public have seen the danger of this organisation [the movement of Gulen] and perceived this as a more serious danger than the corruption allegations. Therefore they support the prime minister."

Cengiz Aktar, a professor of international relations and senior scholar at Istanbul Policy Center, believes that following the elections, Erdogan did not make a statement embracing Turkish society as a whole.

"He said that Turkish democracy is even better than European democracies. This means that he is not going to take any steps for improvement in areas like democratisation and freedom of speech. He is happy with what is going on in Turkey," Aktar said.

Online bans

Turkey has recently blocked YouTube and Twitter, and has reportedly intercepted various Domain Name Systems after the leaks have been shared on the two online platforms.

Ankara says that Twitter has been blocked because it has not carried out court orders to remove some content from the platform while YouTube was banned over the security leaks.

It is unclear who recorded the leaked conversations and posted them on YouTube and Twitter - though officials point a finger at Gulen’s movement.

Many analysts say that the movement of Gulen and AKP used to be allies in the past in their struggle against Turkey's politically dominant military.

Nowadays, Erdogan describes the movement as a "terrorist" organisation in an "alliance of evil" with major opposition parties.

Aktar believes that the government is not going to let the judiciary to investigate the corruption allegations. "This creates a serious legitimacy problem. In the modern world, it is not possible for a democratic government to keep its power like nothing happened," Aktar told Al Jazeera.

On the other hand, Karaca said that the Turkish public did not want the AKP government to brush the corruption allegations under the carpet.

"They want the suspected government members to be cleared of these claims regardless of their support for the government."

Follow Umut Uras on Twitter: @Um_Uras