Iraqi security forces remove destroyed vehicles at the site of a deadly bomb attack, in Baghdad, Iraq, Monday, May 30, 2017. Another bomb exploded outside a popular ice cream shop in the Karrada neighborhood of Baghdad just after midnight on Monday, killing and wounding dozens of civilians, hospital and police officials said. (AP Photo/Karim Kadim)

Iraqi security forces remove destroyed vehicles at the site of a deadly bomb attack, in Baghdad, Iraq, Monday, May 30, 2017. Another bomb exploded outside a popular ice cream shop in the Karrada neighborhood of Baghdad just after midnight on Monday, killing and wounding dozens of civilians, hospital and police officials said. (AP Photo/Karim Kadim)

BAGHDAD (AP) — A massive bombing by the Islamic State group outside a popular ice cream parlor in central Baghdad and a rush- hour car bomb in another downtown area killed at least 31 people Tuesday, Iraqi officials said.

Later in the day, bombings in and around the Iraqi capital killed seven more people.

The attacks come as IS militants are steadily losing territory to U.S.-backed Iraqi forces in the battle for Mosul, the country’s second-largest city. The Sunni extremists are increasingly turning to insurgency-style terror attacks to distract attention from their losses.

ADVERTISEMENT

The nighttime attack outside the ice cream parlor in the bustling Karrada neighborhood killed 17 people and wounded 32, police and health officials said.

A closed-circuit camera captured the moment of the explosion, the video showing a busy downtown avenue with cars driving down the street when the blast strikes. A huge fireball engulfs a building, causing cars to scramble to get away. Other videos of the attack posted on social media show wounded and bloodied people crying for help on the sidewalk outside the ice cream parlor.

In the second attack, an explosives-laden car went off during rush hour near the state-run Public Pension Office in Baghdad’s busy Shawaka area, killing 14, a police officer said. At least 37 people were wounded in that attack, he added.

In separate online statements, IS claimed responsibility for the two attacks, saying its suicide bombers targeted gatherings of Shiites. The Associated Press could not verify the authenticity of the statements but they were posted on a militant website commonly used by extremists.

Later Tuesday, seven people died and 19 were wounded in four separate bombings in and around Baghdad, officials said. The attacks targeted commercial areas and a patrol of Sunni anti-IS tribal fighters, they said. No group immediately claimed those attacks.

All officials spoke on condition of anonymity in line with regulations.

The attacks came just days into the holy month of Ramadan when Muslims fast during daylight hours. After sundown, families break their fast and Baghdad’s restaurants and cafes quickly fill up with people staying up long into the night.

During Ramadan last year, another section of Karrada was hit by massive suicide bombing that killed almost 300 people, the deadliest single attack in the Iraqi capital in 13 years of war. The attack was also claimed by IS.

ADVERTISEMENT

Details of how the militants managed to stage Tuesday’s attacks were not immediately clear. After last year’s attack, Iraqi authorities stepped up security in Karrada, especially in the area of the bombing.

Also Tuesday, a suicide bomber attacked a military patrol in the town of Hit in Iraq’s western Anbar province, killing at least eight people and wounding 10, including security force members, two security officials said. They spoke on condition of anonymity in line with regulations.

In the northern city of Mosul, Iraqi troops are pushing IS fighters out of their last strongholds. Iraqi commanders say the offensive, which recently entered its eight month, will mark the end of the IS caliphate in Iraq, but concede the group will likely increase insurgent attacks in the wake of military defeats.

___

Associated Press writer Sinan Salaheddin in Baghdad and Maamoun Youssef in Cairo contributed to this report.