An official at the interior ministry in Baghdad, speaking on condition of anonymity, said the attack had appeared to target the imam of the mosque, Khadhum Hamid, whom he said was among the dead.
The attack came as the Shia-led government prepared to execute deposed Sunni dictator Saddam Hussein, an event which is expected to further increase the already sky-high tensions between Sunni and Shia factions.
Meanwhile, US forces killed two suspected fighters and wounded two civilians in a raid on an al-Qaeda target in Baghdad on Friday, the US military said.
A US statement said its forces "regret the injuries the local nationals sustained".
In Jurf al-Sakhar, 85km south of Baghdad, gunmen attacked a police checkpoint killing two and wounding seven, a police source said.
The US military said gunmen shot a policeman and a woman and wounded three others, including two children, when they attacked their home in Ramadi on Wednesday.
A US statement said Iraqi police later arrested 13 suspects.
Another British soldier has meanwhile been killed in Iraq, the British military has said.
The unidentified soldier, from 2nd battalion, the Duke of Lancaster's Regiment, was taking part in a routine patrol in an armoured vehicle when it was hit in Basra, southern Iraq, it was said.