Turkish President Recep Tayyip Erdogan's ruling party is appealing the results of the local elections in Istanbul, where preliminary results give the opposition a razor-thin victory.

Nationwide, Erdogan's party won a majority of votes in Sunday's elections, but it lost the capital Ankara to the opposition and is trailing in the tight race for Istanbul.

Bayram Senocak, the ruling party's top official in Istanbul, said Tuesday he has filed appeals to challenge results in 39 districts, seeking a recount to fix alleged irregularities and a reassessment of invalid votes.

The party is also contesting the results in Ankara.

Meanwhile, the opposition's candidate for Istanbul, Ekrem Imamoglu, traveled to Ankara to visit the mausoleum of the secular republic's founder, where large crowds gathered to greet him, chanting "Mayor Ekrem."