More than 60 were injured in the blast, carried out on a tent in a crowded market in a northern district of the city.
So-called Islamic State (IS) claimed responsibility for the attack.
Many Shia pilgrims are taking part in mourning rituals commemorating the killing of the Prophet Mohammed's grandson, Hussein, in the 7th Century.
Reports say a militant detonated a suicide vest in the tent at lunchtime, when it was full of pilgrims.
IS said in a statement, published through the messaging service Telegram, that the attack on Saturday was carried out "in the middle of a gathering" in the Shaab area of Baghdad.
BBC Middle East editor Sebastian Usher says Sunni militants have long used such pilgrimages as targets for attacks causing large scale casualties.
This year, IS revived its bombing campaign in Baghdad killing hundreds of people, in what is seen as a response to the group's loss of much of its territory in Iraq.
In July, a lorry packed with explosives was detonated in central Baghdad's popular shopping district of Karrada in what was the deadliest single bomb attack in Iraq since 2007.
The latest attack comes as Iraqi forces prepare for an offensive in northern Iraq on Mosul, the last IS-held major city in the country.
At least 32 people have died in a suicide attack targeting Shia in Iraq's capital Baghdad, officials say.