BAGHDAD — Bombings that hit markets and other insurgent strikes primarily targeting Iraq’s Shi’ite community killed 31 people on Saturday, challenging government efforts to promote a sense of stability by preventing attacks during a major Muslim holiday.
The bloodshed underscored the difficulties facing Iraq’s leadership as it struggles to keep its citizens safe. Authorities had increased security in hopes of preventing attacks during the four-day Eid al-Adha celebrations, when people are off work and families gather in public places.
The deadliest blast happened on the outskirts of Baghdad and struck near playground equipment that had been set up for the holiday in a market in the eastern neighborhood of Bawiya.
Police officials said eight people were killed, including four children. Another 24 people, including children, were wounded, they added.
‘‘Nobody expected this explosion because our neighborhood has been living in peace, away from the violence hitting the rest of the capital,’’ said Bassem Mohammed, a 35-year-old father of three in the neighborhood who was startled by the blast.
‘‘We feel sad for the children who thought that they would spend a happy time during Eid, but instead ended up getting killed or hurt.’’
Elsewhere, a bomb attached to a bus carrying Iranian Shi’ite pilgrims killed five people and wounded nine, according to police.
The bomb, hidden on the underside of the bus, detonated as the pilgrims were heading to a Shi’ite shrine in Baghdad to mark the holiday.
Authorities have said they planned to increase the number of checkpoints, shut some roads, and deploy extra personnel during the holiday period.
They are also relying more on undercover intelligence agents, said Lieutenant Colonel Saad Maan Ibrahim, a spokesman for the interior ministry.
He emphasized that both bombings took place on the edge of the capital rather than in densely populated areas.
‘‘The terrorists apparently weren’t able to get to the heart of the city. So they chose to attack soft targets on the outskirts,’’ he said.
In the northern city of Mosul, gunmen broke into the houses of two Shabak families, killing a boy and his parents in one and a mother and daughter in the other, according to police. A bomb exploded near the house of another Shabak family, wounding six family members.
Shabaks are ethnically Turkomen and Shi’ite by religion. Most Shabaks were driven out of Mosul by Sunni militants during the sectarian fighting a few years ago.
In Tuz Khormato, about 130 miles north of Baghdad, a car bomb exploded near a neighborhood with a Turkomen Shi’ite majority. Mayor Shalal Abdoul said 11 people were wounded, including three children.
On Saturday night, police said a car bomb explosion near a market in the Shi’ite neighborhood of Sadr City killed seven people and wounded 15 others.
Half an hour later, a second car bomb went off in one of Sadr City’s bus stations, killing six people.
Medics in nearby hospitals confirmed the casualties. All officials spoke on condition of anonymity because they were not authorized to talk to the media.