The coordinated bombings were the latest in a string of attacks to hit Iraq, reviving fears the country is headed back toward the widespread sectarian bloodshed that pushed it to the brink of civil war in 2006 and 2007.
Two police officers said the first bomber detonated his explosives at a security checkpoint near the mosque in Baghdad's northern Qahira neighborhood in an apparent attempt to distract the authorities. The area is a middle-class, Shiite-majority neighborhood.
Amid the commotion, a second bomber slipped past concrete blast walls and into the mosque, where he blew himself up while worshippers were performing midday prayers, according to police officials.
The bombings also wounded 55 people, the officials said.
Most of the casualties were students from the nearby Imam al-Sadiq University for Islamic Studies. Police officials said the university's Shiite students usually perform their midday prayers in the mosque that was hit.
After the blasts, security forces quickly sealed off the area around the simple, unadorned mosque.
Ali Faleh, a university student, said he was inside a stationery shop nearby when he heard a thunderous explosion.
"Everybody ran to the blast site and I saw the body of a colleague who used to be in my class," he said. "The aim of today's attack was only to hurt the Shiites who were there to study or pray, not to fight or kill anybody else."
A medic in a nearby hospital confirmed the casualties. All officials spoke on condition of anonymity because they are not authorized to speak to media.
Violence has surged in Iraq in recent months, along with sectarian and political tensions.
There was no immediate claim of responsibility, but suicide bombings and attacks against Shiite worshippers are frequently the work of al-Qaida's Iraq arm. Sunni extremists such as al-Qaida consider Shiites to be heretics and want to undermine Iraq's Shiite-led government.
Tuesday's bombings follow a string of attacks on Sunni mosques that killed more than 100 worshippers between mid-April and May.
The bloodshed roiling Iraq has risen to levels not seen since 2008. Nearly 2,000 have been killed since the start of April, including more than 220 this month.
On Sunday, a wave of apparently coordinated bombings and a shooting killed at least 51 people. Fifteen people were killed in bomb attacks on Monday, including one caused by a suicide bomber who set off his explosives-laden belt among a group of policemen in Fallujah, west of Baghdad.
Take ABC13 with you!
Download our free apps for iPhone, iPad, and Android devices