Sunday's first attack took place at Jamila, the main wholesale vegetable market in Baghdad's Sadr City, a vast, mostly Shia neighbourhood in the north-east of the capital that has been targeted repeatedly.
"A soldier at the gate of Jamila market opened fire on a suicide car bomb after noticing a suspect vehicle but the terrorist blew up his car," interior ministry spokesman Saad Maan said.
A police colonel and a medical official said at least 12 people were killed and 39 wounded. Maan said the soldier who opened fire on the attacker was among the wounded.
The second attack saw a suicide bomber detonate explosives at a market in the Baladiyat area of east Baghdad, killing at least six people and wounding at least 16, officials said.
IS issued an online statement claiming the Jamila attack, saying it targeted members of Iraq's Shia Muslim majority, whom the jihadists consider heretics.
There was no immediate claim of responsibility for the Baladiyat bombing, but it had the hallmarks of an attack carried out by IS.
Another explosive charge went off when the body of the Jamila bomber was at the morgue, the hospital in Sadr City where his remains were brought said in a statement.
The statement said the explosion occurred when an employee moved the remains while searching for identity papers.
It did not cause any damage or injuries, the statement said, but a photograph of the scene sent by a hospital official indicated that the blast had blown a door off its hinges.
IS claimed an attack on January 2 - also in Sadr City - when a suicide bomber blew up a vehicle packed with explosives among a crowd of day labourers waiting for work, killing 35 people.
The jihadists overran large areas north and west of Baghdad in a swift 2014 offensive that swept through security forces unprepared for the assault.
The number of bombings in the capital declined following the June 2014 offensive, apparently because the jihadists were occupied with holding territory they seized and later defending against government attacks.
Federal forces and units from Iraq's autonomous Kurdish region have since pushed IS back in a series of battles over a period of more than two years.
On October 17, Iraqi forces launched a massive operation to recapture Mosul, the country's last city in which IS still holds significant ground. Iraqi forces punched into the city from the east, retook a series of neighbourhoods and are now approaching the Tigris River, which divides the city into its eastern and western sides.
Copyright Agence France-Presse, 2017