At least 40 people were killed by a suicide bomber at a funeral in Iraq's eastern province of Diyala while a suicide blast at a security checkpoint in Baghdad's western outskirts killed eight members of the security forces, police said on Monday.

The larger attack in Muqdadiya, 80 km (50 miles) northeast of Baghdad, killed six local commanders of the Hashid Shaabi umbrella group of Shi'ite militias who were attending the funeral of a commander's relative, security officials and police in Diyala said. A further 58 people were wounded, the sources said.

Islamic State group, an ultra-hardline Sunni group that controls large parts of northern and western Iraq, claimed responsibility for the blast, according to a statement posted on the SITE monitoring group's Twitter account.

The killing of the commanders, four of whom were from the Asaib Ahl al-Haq militia and two from the Badr Organisation, is likely to inflame sectarian tensions in the mixed province.

Security officials and witnesses said the situation inside Muqdadiya was tense, with dozens of Shi'ite militia members out on the streets but few security forces.

The town's police chief was wounded in clashes with militia fighters who had tried to seize suspected Islamic State group militants from a prison in Muqdadiya, police sources said.

Militia elements have been accused of attacking Sunni Muslim mosques and residents in Diyala following similar bombings in January, but the groups have denied the allegations and blamed Islamic State group.

Iraqi officials declared victory over the Sunni insurgents in Diyala a year ago. While it no longer controls significant territory in the eastern province bordering Iran, Islamic State group has remained active there.

A separate attack in the western Baghdad outskirts of Abu Ghraib followed an offensive by Islamic State group militants on army and police positions in the same area on Sunday which left 24 people dead but was eventually repelled by counter-terrorism forces and army attack helicopters.

Monday's blasts follow the deadliest bombing inside the capital so far this year, which killed 78 people in a Shi'ite district on Sunday.