Scores of people were wounded in the blasts, thought to have been the work of two suicide bombers.
The first assailant detonated his vest inside the mosque and the second blew himself up when security forces gathered at the site, reports say.
The so-called Islamic State (IS) group claimed the attack at the Rasul al-Azam mosque in the Shuala neighbourhood.
IS said the bombers had targeted "apostates" - a term the Sunni Muslim jihadist group uses to refer to Shia Muslims.
The "double tap" is a technique used to maximise casualties, where a second device is detonated at the site as people flee or emergency services arrive.
At least three of the victims were members of the security forces.
A police source told Reuters news agency: "Two suicide bombers wearing explosive belts blew themselves up in front of the Rasul al-Azam in the Shuala district.
"The first suicide bomber blew himself up among the worshippers as they left, the second explosion targeted police forces who had arrived to treat the wounded."
IS has carried out a string of deadly attacks on Shia mosques in Iraq.
It says it carried out an attack on a Baghdad shopping centre last month which killed at least 18 people.
At least 15 people have been killed in a so-called "double tap" bombing at a Shia  mosque in Iraq's capital Baghdad.