The bloodshed comes as officials count votes from the April 30 general election amid a protracted surge in violence that has killed more than 3,200 people this year.

The bloodletting has fuelled fears that Iraq is slipping back into the all-out sectarian conflict that left tens of thousands dead in 2006 and 2007.

Authorities have been quick to blame external factors such as the civil war in neighbouring Syria for the rise in unrest.

However, analysts and diplomats say the Shiite-led government must do more to reach out to the disaffected Sunni Arab minority to undermine support for militancy.

In the north, militants attacked a small military base, abducted 20 soldiers and later shot them dead. Their bodies were found in the area on Saturday night, according to security officers and a morgue employee.

The powerful Islamic State of Iraq and the Levant (ISIL) jihadist group claimed the attack in a statement, saying it had targeted members of the "Safavid army", a pejorative term to link Iraq's security forces with those of Iran, which was once ruled by the Safavid empire.

"God willing, these operations will not stop," the statement added.

ISIL and an army major general said the kidnappings took place in Nineveh province on May 5.

The previous month, militants killed 12 soldiers and wounded 15 in an assault on a military base west of Mosul, the capital of Nineveh province.

The province, where militants hold considerable sway, is one of the most consistently violent areas in Iraq.

Militants opposed to the Baghdad government frequently target the security forces but it is rare for such a large number of soldiers to be kidnapped at once, especially from a military position.

Meanwhile, violence in Baghdad and north Iraq killed 21 people on Sunday, security and medical officials said.

Four policemen, two soldiers and a civilian were killed in attacks in Nineveh province while one person was gunned down in Salaheddin province.

In Kirkuk province, militants killed a policeman and six soldiers in two separate attacks.

And two people were shot dead in the capital, while four more people, including three anti-al-Qaeda militiamen, were killed on the city's outskirts.