Lieutenant Rayid Othman said on Friday that the explosion happened at 11.15pm (1915 GMT) on Thursday outside the Imam al-Mahdi mosque in Baghdad's Saadiya neighbourhood.
The blast caused damage to the mosque, nearby shops and houses. In the garden of one of the houses, two brothers aged five and nine years were killed and their mother was injured, Othman said.
Groups bent on sparking widescale sectarian conflict in post-Saddam Hussein Iraq regularly have targeted places of worship.
US soldiers killed
Four US soldiers were killed in three separate incidents in Iraq, according to US military statements on Friday.
Two soldiers were killed in a drive-by shooting attack on their convoy in central Baghdad on Thursday, while another was killed a day earlier in an "indirect fire attack" - a term normally designating mortar fire - on a base in the western city of Ramadi, west of Baghdad.
Another soldier died in a road crash after a bomb exploded near US patrol vehicles early on Friday morning near Taji, north of the capital.
As of 19 May, 1627 members of the US military have died since the beginning of the Iraq war in March 2003, according to an Associated Press count.