Turkish President Recep Tayyip Erdogan has defended his party's move to demand a full recount of votes cast in mayoral elections in Istanbul, claiming that "almost all" of the voting was marred by irregularities.

Erdogan suffered a major setback in last week's local elections after the opposition took control of the capital, Ankara, and won a tight race for Istanbul.

A recount of votes that were previously deemed invalid, demanded by Erdogan's ruling party, is taking place in several districts, but the party now wants a recount of all of the ballots.

Erdogan said: "We have determined that certain (irregular) acts were carried out."

The opposition, which now has a 14,000-vote lead, is demanding that the ruling party concede victory in Istanbul.