Protesters have attacked the leader of Turkey's main opposition party during the funeral of a soldier who was slain during clashes with Kurdish rebels.

Television footage on Sunday showed some protesters hitting Kemal Kilicdaroglu on the head as security officials tried to escort him away from the crowd.

The attack comes weeks after Kilicdaroglu's pro-secular Republican People's Party took control of the key cities of Ankara and Istanbul in Turkey's March 31 local election away from President Recep Tayyip Erdogan's ruling party.

Erdogan had led a highly divisive electoral campaign, portraying the elections as a matter of national survival and equating opposition parties with terrorists.

The soldier was among four killed Saturday in a clash against the outlawed Kurdistan Workers' Party rebels near Turkey's border with Iraq.