The blast in the Harthiyah area, which also wounded at least 30 people, is the latest in a string of bombings in the Iraqi capital that have killed dozens of people in recent days.
Accounts differed as to whether the bomber struck at the gate or inside the mosque, where some of the sources said mourners were gathered at the time of the explosion.
There was no immediate claim for the attack, but suicide bombings are almost exclusively carried out by Sunni jihadists in Iraq, including members of the Islamic State (IS) group, which has seized large areas of Iraq since June.
The militants have been kept from reaching Baghdad in force and would face major challenges if they tried to occupy part of the city, but they are able to strike the capital with deadly bombings.
Members of Iraq’s Shiite majority, whom Sunni extremists consider to be heretics, have suffered the brunt of the blasts.
In further violence on Sunday, a roadside bomb exploded near a security forces patrol in the Tarmiyah area north of Baghdad, killing at least four people and wounding at least eight, officials said. -AFP