The attack in a predominantly Shia neighbourhood, which also left 60 people wounded, came days after Al-Qaeda warned it would continue targeting Shia Muslims and barely a month after US troops completed their withdrawal.
It raised fresh concerns about the ability of domestic forces to provide security.
The 11:00 am (0800 GMT) attack struck outside Zafraniyah hospital in east Baghdad as a funeral procession was transporting the bodies of a family who had been killed in the capital a day earlier.
Medical and security officials said at least 31 people were killed and 60 wounded. Eight security officers and four women were among those who died. Attacks elsewhere in Iraq left three dead and three hurt.
Helicopters flew overhead as a heavy security presence cordoned off the site of the explosion, while distraught witnesses screamed in anguish, surrounded by the remains of the dead, their clothes and shoes, and chunks of twisted metal.
Outside the hospital, groups of men called out names, searching for missing relatives.
Inside, people crowded around medics to ask about their loved ones, but one nurse said simply: “I cannot tell you anything -- there are only arms and legs, we do not know who they belong to.”Abu Jassim, who was outside the hospital when the bomber struck, laid the blame for the attack with the security forces. “They are responsible for this; there were a large number of policemen and they did not stop the car or check it.
“All this reminds me exactly of what was happening in 2006 and 2007, when all of our days were bloody,” the 57-year-old said, referring to the height of Iraq's sectarian bloodletting.
Several nearby shops and houses were burned or destroyed, with many of their windows shattered, while an ambulance and several cars were completely burned out.
“I saw a yellow taxi going in the direction of the funeral procession, and then it exploded,” said Ayman Rabiyah, an employee of the Baghdad municipality.
“The funeral corpses went flying into the air. I carried the dead body of a young girl, and the corpse of a man whose head had been blown off, to the hospital.”
The blast hit the funeral procession of Mohammed al-Maliki, a real estate agent who was killed along with his wife and son in west Baghdad on Thursday.
Maliki and his family were killed by gunmen in Yarmuk, although there have been differing accounts of the attack itself.
A doctor at Yarmuk hospital said the attackers burst into a real estate agency and killed three people, while a security official said four people, including two real estate agents, died when gunmen opened fire on their car.
Separate gun and bomb attacks in Baghdad and the main northern city of Mosul, left three people dead and three wounded, security officials said.