(CNN)Turkey's Justice and Development Party (AKP) is officially contesting its losses in this week's local elections.
According to results announced this week, President Recep Tayyip Erdogan's AKP lost control of Istanbul, the country's financial capital. It also lost the capital city Ankara, where the opposition People's Republican Party (CHP) won more than 50 percent of votes.
AKP party officials from both cities on Tuesday announced objections to the results.
At a press conference, Bayram Senocak, the party's top official in Istanbul, announced his party's objection to the results in 39 voting districts.
"We have detected huge differences between the signed and stamped ledgers that the counted votes are entered in the first place and the figures submitted to the Supreme Electoral Board, and this has been the subject of our objection appeal," he said.
"Also, we are talking about 319,570 invalid votes which can change the outcome," he added.
According to the state news agency Anadolu, invalid votes in five Istanbul districts will now be recounted. "The decision was taken by respective district electoral boards following appeals from AKP" Anadolu reported.
The recount in the districts -- Beykoz, Cekmekoy, Sile, Bayrampasa and Catalca -- will take place on Wednesday.
AKP and its predecessor have consistently won in Istanbul's local elections since the 1990s, when Erdogan launched his political career there as mayor. He served as the face of AKP's local election campaigns this year, holding rallies across Turkey in support of the party.
AKP contests election results in Ankara
In Ankara, the provincial AKP chairman also announced his objection to local results for all 25 districts of Ankara.
Hakan Han Ozcan said that his party had detected irregularities in 3,217 ballot boxes. "We cannot allow for the votes to be wasted while we are making a huge effort for each vote to count," he said. "In many ballot boxes, we have detected that the figures on different ledgers were not added correctly."
It would be the first time in 25 years that the Islamist party loses its grip on Ankara.
The Turkish Supreme Electoral Council (YSK) has not issued any statement about the validity of votes cast in Istanbul and Ankara.