IS seized swathes of Iraq in a lightning offensive in 2014, before being beaten back by a counter-insurgency campaign supported by a US-led military coalition.
The Iraqi government declared the Sunni extremists defeated in late 2017, but they retain sleeper cells which continue to hit security forces with asymmetric attacks.
Jihadist cells regularly target the Iraqi army and police in northern Iraq, but this attack was one of the most deadly this year.
A 19 July bombing claimed by IS officially killed 30 people in the Al-Woheilat market in Sadr City, a Shiite suburb of Baghdad.
International coalition troops in Iraq currently number around 3,500, of which 2,500 are US troops.
But Washington has been drawing down its military presence amid attacks on facilities it uses by Iran-aligned armed groups and has said that from next year the role of US troops will be limited to training and advising their Iraqi counterparts.
Last Sunday, French president Emmanuel Macron visited Iraqi Kurdistan and expressed concern about an IS "resurgence" in both Iraq and Syria.
He also said that French soldiers deployed in Iraq as part of the international coalition will remain in the country "no matter what choices the Americans make".