Turkish President Recep Tayyip Erdogan has declared victory in Sunday's local elections but the opposition's win in the capital has dealt a significant blow to his party's dominance.

Unofficial results published in state media show the secular Republican People's Party or CHP's candidate won the metropolitan mayor seat of Ankara. The capital city was held by Erdogan's Justice and Development Party, or AKP, and its Islamic-oriented predecessor for 25 years.

Both the CHP and AKP candidates declared victory in the race for mayor in Istanbul, Turkey's largest city, though vote count is still underway and unofficial results too close to call.

The AKP made gains in southeastern provinces that were strongholds for a pro-Kurdish party.