"While we're fighting outside, I have to say, we had people doing us wrong from the inside too," said Erdogan, while addressing a gathering of the AKP in the capital Ankara on Saturday.
The March 31 elections saw Turks voting to elect mayors, municipal councils, and other local officials. Erdogan’s AKP secured an overall victory with some 51 percent of the votes, Presstv Reported.
The ruling party, however, suffered major defeats in the elections, which handed a victory to the main opposition Republican People's Party (CHP) in the political power base, Ankara and the third-largest city of Izmir.
The city of Istanbul seems to have come out from under the AKP's 25-year rule as the results showed the CHP had narrowly won control of the country's economic, cultural and historic center.
"What is going on in which province, in which district, all that information come to us. We know it all ... For the future of this organization, we will call them to account. We're not going to carry them on our backs," Erdogan said.
The Turkish president said his party would keep up its legal campaign challenging the results and calling for recount.
"Until the last moment, we will continue our legal struggle. It is certain that there is a scam here. We have to get the case resolved, so that we can find peace," he said.
"Although we have won the districts, we will question why we lost the big cities," he said, adding, "We need to focus on what to do and how to evaluate this process, especially in the metropolitan cities".
‘Istanbul mayoral election questionable’
He further raised doubts about the credibility of the elections in Istanbul, saying documents show a very serious organized set-up in the polls.
Erdogan said that his ruling party had succeeded in local elections held last month.
"Every election is an exam, struggle and an opportunity for assessment. We substantially succeeded in the March 31 local elections," said Erdogan.
Elsewhere in his remarks, the Turkish leader said Ankara was determined to continue its fight against terrorist groups in Syria.
Ankara, which has been assisting several militant groups fighting to topple the government of President Bashar al-Assad, has moderated its initial hostility toward Damascus and been working with Iran and Russia to restore peace to Syria within the Astana talks.
He also said that Turkey would take measures to acquire the Russian-made S-400 missile defense system despite US pressures from the United States.
“We will continue taking steps to clear terror swamps in Syria and procure S-400 and similar security entrenchments," he said.
Moscow and Ankara finalized an agreement on the delivery of the S-400 missile systems in December 2017. In April 2018, Erdogan and Russian President Vladimir Putin announced an agreement on expediting the delivery of the missile systems. At the time it was said that the delivery could be made between late 2019 and early 2020.
The deal has drawn concerns among some of Turkey’s NATO allies, particularly the US, who claim the missile batteries are not compatible with those of the military alliance.
The missile defense system, whose full name is the Triumph Mobile Multiple Anti-Aircraft Missile System (AAMS), is an advanced Russian missile system designed to detect, track, and destroy planes, drones, or missiles as far as 402 kilometers away. It has previously been sold only to China and India.