Turkish President's ruling party wins nearly 45 percent of the votes in local elections, though the opposition regains hold of the capital.

Turkish President Recep Tayyip Erdogan's ruling party led Sunday's mayoral elections but suffered setbacks in the capital of Ankara, as the opposition regained hold of the capital, The Associated Press reports.

The opposition also made significant inroads in other parts of Turkey in the local elections, which Erdogan had depicted as a fight for the country's survival.

Erdogan's Islamic-based Justice and Development Party (AKP) took nearly 45 percent of the votes in the elections after 90 percent of the more than 194,000 ballot boxes were counted, according to state broadcaster TRT.

The secular, main opposition party, the Republican People's Party (CHP) had 30 percent.

The CHP's mayoral candidate for Ankara, Mansur Yavas, however, won control of Ankara after 25 years of rule by the AKP and a predecessor party. The 63-year-old lawyer received more than 50 percent of the votes, according to TRT.

The CHP and its allies also posted gains elsewhere, increasing the number of city mayoral seats from 14 in the previous local elections in 2014 to 20, according to preliminary results.

Sunday's elections were a first test for Erdogan since he won re-election last June under a new system of government that gave the presidency expanded powers.

Meanwhile, according to AP, the pro-Kurdish, People's Democratic Party appeared to have regained seats in several districts in Turkey's mostly-Kurdish southeast region where Erdogan's government had replaced elected mayors with government-appointed trustees, alleging that the ousted officials had links to outlawed Kurdish militants.

However, the party lost control of two key cities in the region.