President Recep Tayyip Erdogan on Friday accused the US and Europe of "meddling" in Turkey's affairs after statements from Western allies following his ruling party's challenge to local election results.
Erdogan and his AKP suffered an upset in Sunday's ballot when results showed the party lost the capital Ankara and was narrowly defeated in Istanbul, the country's largest city and economic hub.
While the United States has called on Turkey to accept the results, the European Union urged Ankara to allow elected officials to "exercise their mandate freely".
But Erdogan rejected the remarks and told the US and Europe to "know your place".
"America and Europe are... meddling in Turkey's internal affairs," Erdogan said in his first direct remarks to journalists since Monday.
"Turkey gave a democracy lesson to the whole world," he added.
US State Department spokesman Robert Palladino said "free and fair elections are essential for any democracy, and this means acceptance of legitimate election results are essential" during a briefing on Tuesday.
EU spokeswoman Maja Kocijancic on Monday said Brussels expected elected local representatives to be able "to exercise their mandate freely and in line with the principles of the Council of Europe (rights group) to which Turkey is of course party."
Erdogan's AKP challenges Istanbul results in Turkey election
Andrew Dawson, head of a delegation from the Council of Europe in Turkey to observe the vote, said on Monday his team was "not fully convinced that Turkey currently has the free and fair electoral environment which is necessary for genuinely democratic elections in line with European values and principles."
'Over by weekend'
The two rival Istanbul candidates both declared victory soon after the vote when initial results showed them in a dead heat. The AKP appealed after electoral authorities later said the opposition's Ekrem Imamoglu had taken a very slim lead.
The Turkish head of state hit out at American and European criticism over his party's push for appeals.
"In your own countries, you have launched appeals."
Runner up in Turkish elections accepts Erdogan as President
Erdogan fought hard before the vote, holding rallies across Turkey where he described the election of mayors and district councils as a battle for the nation's survival.
But voters, concerned with the rising cost of living, double-digit inflation and unemployment, opted for the opposition in the country's two biggest cities.
CHP opposition candidate Imamoglu told Fox Haber broadcaster earlier the difference between himself and the AKP's candidate, Binali Yildirim, was now 18,742 votes.
He said nearly 120,000 previously annulled votes had been recounted in 17 Istanbul districts, with 2,184 extra votes being allowed for Yildirim, and 785 for himself.
Imamoglu estimated the final difference could finish between 18,000 to 20,000 once counting ended, probably by Sunday. Nearly 200,000 more votes still need to be recounted, he said.
"It should be over by the end of the weekend," he told the station.
The AKP has said the recount will show its candidate won.
Election authorities provide ongoing recount details to observers from both parties to ensure transparency. Political parties have until April 10 to challenge the results.
A defeat in Istanbul would be especially sensitive for Erdogan who made his political career as mayor of the city. The AKP or its predecessors had held both cities since 1994.
AKP secretary general Fatih Sahin on Thursday said the party would also appeal to the Ankara provincial election board for the city's 25 districts for another recount.
Opposition candidate Mansur Yavas of the CHP beat the AKP's Mehmet Ozhaseki in Ankara, according to preliminary results.
After an initial recount in Ankara, Ozhaseki got 1,805 extra votes, prompting the party to appeal to the next level of electoral authorities as is allowed by law.
AKP officials have said they believe there was a huge discrepancy in both cities between ballots cast at polling stations and the actual data sent to election authorities.
Turks begin voting in local polls which Erdogan could lose in big cities
Erdogan on Friday said his party won 24 out of 39 districts of Istanbul but said: "The final decision will be taken by the Supreme Election Board."