The extremist group, accused of executing at least 25 Yazidi prisoners in the northern city of Tal Afar, said it was targeting members of a Shia militia as revenge for the fighting in nearby Anbar province.
The two car bombs in Baghdad went off about 10 minutes apart late Saturday in the central Karrada district, known for its restaurants, cafes and ice cream parlors.
Police said the victims were mainly shoppers and people commemorating the death of Imam Ali, a key figure in Shiite Islam.
Iraqi forces in Anbar are battling Islamic State militants, who control some 65 percent of the province.
The fighting has caused 114,000 residents to flee elsewhere.