Four men from each side had been decapitated after being caught by the opposing side during battles on Saturday, Ghalib Mujahid, the governor of the Achin district, said.
During a fight with gunmen affiliated with the IS, he said, four members of a militia loyal to Zahir Qadir, deputy speaker of parliament, were taken hostage and beheaded.
In revenge, four of five IS gunmen held by Qadir’s militia were beheaded, Mujahid said. Their heads were placed on piles of stones along a main road through Achin, he said.
It is not unusual for powerful figures in Afghanistan to control personal militias, though the central government and international organizations such as the United Nations have expressed concern about a proliferation of armed groups that are not part of the government’s security force.
Achin is one of four districts that Afghan officials say has come under IS control in recent months. Government forces have returned to the area to try to dislodge the extremists, who also fought fierce battles with the rival Taliban in the region during the summer months.
IS has a presence in other volatile regions of Afghanistan, but Nangarhar appears to be their main powerbase.
Mujahid said the decision to behead the IS gunmen had been made by Qadir’s militia leaders.
‘‘We condemn the act of Daesh, and of course we condemn the act of Qadir’s men here,’’ he said, using an alternative name for the Islamic State group. ‘‘It is not acceptable for either side to act like this.’’
Meanwhile, in southern Helmand province — where the Taliban are fighting government forces for control of a number of districts — a roadside bomb killed a local police commander and two of his bodyguards, said provincial police spokesman Shah Mahmood Ashna.
He said that other two police officers were wounded in the explosion in the provincial capital of Lashkar Gah.