At least 40 people were killed in a suicide attack near a Shiite shrine north of Iraq's capital, the latest assault claimed by the Islamic State. (Reuters)

At least 40 people were killed in a suicide bombing at a Shiite shrine north of Baghdad, medical officials said Friday, as Iraqis took to the streets of the capital to demonstrate against a government they say is failing to protect them.

Three suicide bombers dressed in military uniforms opened fire on worshipers gathered at the shrine in Balad late Thursday, said Brig. Gen. Yahya Rasoul, a spokesman for the Iraqi military. Two then detonated their explosives at the shrine’s gate, and the third was killed before he could trigger his device, Rasoul said.

By Friday afternoon, the death toll had climbed to 40 people, said Saib al-Shami, deputy head of Balad hospital. He said 74 people were wounded. Seven of those killed were not immediately identified because they were burned beyond recognition in the fire that followed the bombing, Shami said. The Health Ministry confirmed the figures.

The incident comes less than a week after the Islamic State’s deadliest single suicide bombing in Iraq, which killed at least 292 people in the Karrada neighborhood of Baghdad early Sunday. A spate of attacks in several countries have been linked to the group during the Muslim holy month of Ramadan, a surge of violence that has coincided with Islamic State losses in Iraq and Syria.

Shiite fighters loyal to radical cleric Moqtada al-Sadr gather at the site of an Islamic State suicide attack in Balad, Iraq, July 8, 2016. (Thaier Al-Sudani/Reuters)

The killings have triggered protests in the capital, where there were already mass demonstrations against the government. Amid growing discontent, Prime Minister Haider al-Abadi sacked the head of security for Baghdad on Friday, according to a statement from his office. Other security officials were also fired, the statement said, without providing further details.

“Our blood became cheap in Karrada and Balad,” said Hadi Talib, 40, as he marched from a main square in Baghdad to the bomb site. However, he said demonstrations felt futile.

“The solution is to protest inside the Green Zone and burn it like they are burning our cities and killing our sons,” he said. The Green Zone is a fortified area in central Baghdad in which government ministries and parliament are located.

Protesters have stormed the Green Zone twice this year as Shiite cleric Moqtada al-Sadr rallied his supporters against government corruption. Those protests paused during Ramadan but have been building since the Baghdad bombing.

Hussein Ali, 34, said “civil disobedience” was the only answer. “I wish Saddam wasn't removed,” he said, in reference to Iraq’s former leader. “I was against him, but now I understand why he was executing people like those who are in power now. These people are not fit to lead sheep.”

As bodies were still being identified from that attack, the militants struck again.

On Thursday night, the shrine in Balad, about 55 miles northwest of Baghdad, was packed with pilgrims visiting to mark Eid al-Fitr, a festival held at the end of Ramadan, said Ali Bandar, 27. Most of the dead were pilgrims, he said.

The Islamic State, which considers Shiite Muslims heretics, asserted responsibility in a statement circulated online. Its suicide bombers killed the guards at the shrine and then fought with Shiite militiamen who arrived at the scene, it said. An eight-hour standoff ensued, after which several fighters detonated explosive belts, causing “great destruction,” the statement said.

Sadr ordered his militiamen to deploy to protect the shrine.

The loss of life over the past week increases pressure Abadi, who has been trying to quell months of street protests calling for reform.

Sadr, who has positioned himself as a champion of reform and has hundreds of thousands of supporters, said the bombing underscores the need for a cabinet reshuffle.

Interior Minister Mohammed Ghabban has already submitted his resignation in the wake of the bombing, though he has not yet been replaced.

Morris reported from Beirut.