Dozens were wounded in the violence, and locals exacted a grim revenge on one man suspected of being a second attacker in the mosque bombing, which comes amid Iraq's worst bloodshed since 2008. Authorities have sought to tackle the unrest with a string of measures ranging from massive security operations to implementing tight traffic restrictions in the capital in a bid to stem the number of car bombs.
But attacks have continued to hit much of the country, with more than 4,000 people killed in violence already this year. The worst of Wednesday's violence struck the confessionally mixed north Baghdad neighbourhood of Waziriyah, where a suicide bomber blew himself up at a mosque at around 6:40 pm as worshipers were exiting following evening prayers.
At least 30 people were killed and 55 others wounded, security and hospital sources said, speaking on condition of anonymity. Several nearby shops were also badly damaged by the blast. Immediately after the bombing, locals spotted a man they suspected was about to blow himself up as well, and gunned him down before setting his corpse ablaze, the sources said.
No group immediately claimed responsibility for the attack against the Tamimi mosque, a Shiite place of worship, but Sunni militants linked to Al-Qaeda frequently set off attacks against Iraq's Shiite majority, who they regard as apostates.
Suicide bomb outside mosque kills 39
Violence elsewhere in the country killed nine people, including four in the restive northern province of Nineveh. In three separate attacks in the province, which remains one of Iraq's least stable, gunmen killed three people, among them a school principal who was shot dead at his house.
And in provincial capital Mosul, a magnetic "sticky bomb" attached to a car killed another person. Three attacks in and around the ethnically mixed city of Kirkuk left two dead, including a senior security official, while a Sunni anti-Qaeda militiaman escaped assassination. A sticky bomb killed one person in south Baghdad, and another died in a roadside bombing in a town on the capital's southern outskirts, while a gunman on a motorcycle killed a Sunni imam near the southern port city of Basra.