A suicide bombing in Baghdad targeting Shiite Muslims taking part in an annual pilgrimage has killed nine people and wounded another 21, Iraqi officials said.

Monday's attack targeted a checkpoint along a route used by pilgrims in the northern Baghdad neighbourhood of al-Shaab.

Police officials said four soldiers are among the dead.

It was the first attack on Shiite pilgrims in Baghdad during the lead-up to the religious commemoration known as Arbaeen, when Shiite faithful converge on the holy city of Karbala.

The annual commemoration is often marked by violence despite tight security measures to protect the pilgrims, many of whom travel to Karbala on foot.

Arbaeen marks the passing of 40 days after the anniversary of the seventh century martyrdom of Imam Hussein, the grandson of the Prophet Muhammad and a central figure in Shiite Islam. Iraqi officials say they expect the number of pilgrims this year to top last year's record of more than 17 million.

Earlier on Monday, two roadside bombs in commercial districts of Baghdad killed five people and wounded 16, according to the Iraqi security officials.

No one claimed Monday's attacks, but the Islamic State group has repeatedly targeted the country's Shiite majority. The extremist group swept across Iraq in 2014, capturing a third of the country and declaring it part of a self-styled Islamic caliphate.

On Monday, Iraq's military told civilians to leave the IS-held city of Ramadi, 70 miles west of Baghdad, indicating that an operation could soon be under way to retake the city. IS captured Ramadi, the capital of Anbar province, in May.

The military statement, broadcast on Iraqi state TV, said families should leave the city from the south.

The US-led coalition carried out seven airstrikes near Ramadi on Saturday, targeting IS fighters, positions and weapons caches.