On Monday, nine Iraqi policemen were killed in a bombing in Kirkuk governorate in another attack claimed by the group.
During the Diyala attack, villagers tried to confront a group of ISIS fighters on motorbikes in a village in the governorate's Khalis district, but were quickly overpowered, the Iraqi News Agency reported.
Uday Al Khadran, an official in the town of Al Khalis where the attack took place, said “dozens” of residents had confronted the group, some of them without weapons. He said a security operation was continuing to capture the terrorists.
An interior ministry official, who asked not to be identified, blamed ISIS for the attack and recalled that villagers had formed a paramilitary group to defend their land against the terrorists in 2014.
The defence ministry said it had sent a high-ranking delegation to Diyala province “to throw light on the circumstance of the criminal action”.
Analysts say remnants of ISIS are hiding in remote villages, moving through wadis and rough desert terrain to conduct opportunistic attacks.
The presence of Iran-backed militias in Diyala has also raised tensions, in a province that is a patchwork of religious and ethnic groups, said by some to be a "mini-Iraq."
ISIS seized large areas of Iraq and Syria in 2014, declaring a “caliphate” which they ruled with extreme violence before their defeat in late 2017 by Iraqi forces backed by a US-led military coalition.
The group lost its last Syrian bastion, near the Iraqi border, in 2019.
Despite the setbacks, which have left ISIS a shadow of its former self, the group can still call on an underground network of between 6,000 and 10,000 fighters to carry out attacks on both sides of the porous border, a UN report said earlier this year.
Last Wednesday, three Iraqi soldiers were killed when a bomb exploded during a security operation in the Tarmiyah district, north of Baghdad. Among the dead was the commander of the 59th Infantry Brigade.
No one claimed responsibility for the deaths, but ISIS remnants are active in the area and have previously claimed similar attacks.