BAGHDAD -- Iraq's prime minister vowed Tuesday to keep up the fight against the Islamic State group, a day after an IS suicide attack on a shopping mall in Baghdad killed 18 people and a wave of retaliatory attacks targeted Sunni mosques.

Touring the bombed and destroyed mall in the eastern Shiite-dominated area of New Baghdad, Haider al-Abadi described the attack as a "desperate attempt" by militants after they lost control of the key western city of Ramadi, the capital of Anbar province.

Iraq's government will "spare no efforts" to expel IS forces from the country, al-Abadi said.

Gunmen stormed the Jawhara Mall on Monday after setting off a car bomb and launching a suicide attack at its entrance. Iraqi forces later surrounded the building, landing troops on the roof before clashing with attackers inside, killing two gunmen and arresting four. Along with the 18 killed, around 50 people were wounded.

After the attack, IS posted an online statement saying it targeted an area where many Shiite Muslims are known to gather and warned of "worse" to come. The Associated Press could not immediately verify the authenticity of the statement, but its language and phrasing is consistent with past IS claims of responsibility.

Later Monday, back-to-back suicide attacks in the Shiite-dominated town of Muqdadiyah, about 90 kilometres north of Baghdad in Diyala province, killed at least 24 people and wounded 52. And in a crowded area in southeast Baghdad, a car bomb explosion killed at least five people and wounded 12 others.

Angry mobs then attacked several Sunni mosques in apparently retaliatory attacks, prompting security forces to impose a curfew in the area, Sunni lawmaker, Raad al-Dahlaki, told The Associated Press. Al-Dahlaki, who's from Diyala, described the mobs as "gangs outside the government control," calling on the government to chase them down.

The head of the Sunni Endowment, sheik Abdul-Latif al-Himaim, said one mosque imam was killed and two mosques were completely destroyed in the attacks. The rest were partially damaged, he added.

"Organized gangs were behind the attack seeking to inflame sectarian tensions," he said.

Alarmed by Muqdadiyah events, the UN Special Representative for Iraq, Jan Kubis, called on "all sides to refrain from being drawn into a cycle of reprisals" and warned in a statement that the perpetrators seek to take "the country back into the dark days of sectarian strife."

Iraq is going through its worst crisis since the 2011 withdrawal of U.S. troops. In the summer of 2014, the Islamic State group blitzed across large swaths of the country's north and west, capturing Iraq's second-largest city of Mosul and the majority of the western Anbar province.

Last month, the group suffered a major defeat when Iraqi forces drove the extremists out of the western city of Ramadi, the capital of the sprawling Anbar province. Islamic State still controls much of northern and western Iraq.

Associated Press writers Murtada Faraj, Susannah George and Muhanad al-Saleh in Baghdad contributed to this report.