But children have been caught in Iraq’s violence before, most recently when at least 30 were killed in a powerful bomb attack at the Justice Ministry in October. Many were at day care centers in the building.

During the war, children have been used to get through checkpoints in suicide car bombings. They have been kidnapped, caught in the cross-fire of warring factions and killed in errant missile strikes and in roadside bombings.

Image Iraqi children gathered around a blast site in the Shiite neighborhood of Sadr City in Baghdad. Credit... Eros Hoagland for The New York Times

The school that was the site of the explosion on Monday is in an alley in an impoverished section. The bomb crater  15 feet wide and 6 feet deep  was just outside a wall around the school.

“There was trash being burned outside, and a cable from the electricity had just fallen, so my teacher was looking out the window,” said Ritha Kadhim, 12, speaking from his hospital bed, one of his eyes closed and swollen, the other filled with blood. Then there was an explosion. “I fell down and everything was dark. One of my friends helped me up. We were all going out when I fell again, and the next thing I recall is waking up in the hospital. And now I just want to know if my friends are O.K.”

While it was unclear whether the explosion was an accident, officials say militants behind a recent spate of attacks on security forces want to regain a footing in their former strongholds. In particular, militants have attacked members of the Awakening movement, a predominantly Sunni Arab force recruited to fight Sunni Islamic extremists.

Early Monday, gunmen ambushed a checkpoint run by Awakening members in northern Baghdad. They killed five guards using guns equipped with silencers, according to the local police.