Body parts of victims lay scattered across the previously bustling market, which had been crowded with shoppers buying food ahead of the Islamic festival of Eid al-Adha.
More than 60 people were wounded, a police source said. The death toll could rise as some of the wounded were in critical condition.
Women and children were among the dead and some shops burned down as a result of the explosion.
The attack took place in the Wahailat market in Sadr City.
“A terror attack using a locally made IED (improvised explosive device),” was responsible, Iraq’s interior ministry said in a statement. Video footage shared on social media after the blast showed bloodied victims and people screaming in terror.
In a message posted to its Telegram channel, Daesh claimed responsibility for the attack, saying one of its fighters blew up his explosive vest among the crowds.
Iraqi President Barham Salih called the bombing a “heinous crime” and offered his condolences, Al Jazeera reported.
“They are targeting our civilians in Sadr City on the eve of Eid,” Salih said in a message on Twitter. “They do not allow people to rejoice, even for a moment.”
“It’s a sad Eid night in Iraq,” the International Committee of the Red Cross said. “Our deepest sympathies and sincere condolences to those who lost their loved ones.”
It was the third time this year that a bomb hit a market in the densely populated neighborhood. In April, at least four people were killed in a car bomb attack in Sadr City. That blast was caused by an explosive device attached to a parked car at the market.
Prime Minister Mustafa al-Kadhimi placed the commander of the federal police regiment responsible for the area of the marketplace under arrest, according to an Iraqi military statement. It also said an investigation was launched.
Once an almost daily occurrence in Baghdad, large bomb attacks have slowed since Daesh was defeated on the battlefield in 2017.
Attacks persist, however. In January, more than 30 people were killed in a twin suicide bombing in a busy commercial area in central Baghdad. It was the deadliest bombing in three years to strike Iraq’s capital.