There was no immediate claim of responsibility for the attacks on three mosques, and it was unclear whether there was any connection to the storming of the protest camp. Sunni extremists such as Al Qaeda have in the past targeted moderate Sunnis. But if Shi’ite militias were behind the attacks, it would raise fears of a return to the open sectarian fighting of 2006 and 2007.

The raid on the protest camp drew harsh condemnations from Sunni leaders and foreign diplomats and raised fears that Iraq would follow Syria into the descent of open warfare.

Prime Minister Nouri al-Maliki swiftly announced the formation of a special committee to investigate what happened.

‘‘What happened today is a total disaster,’’ Parliament speaker Osama al-Nujaifi, a Sunni, said at a televised news conference. He appealed for calm and called for those responsible to stand trial. ‘‘If this bloodshed spreads to other provinces, God forbid, there will be a huge fire that we cannot put out.’’

The security crackdown began at dawn in the former insurgent stronghold of Hawija, about 150 miles north of Baghdad. Like many Sunni communities, the town has seen months of protests accusing the government of neglect and pursuing a sectarian agenda.

The raid occurred four days after a police checkpoint near the town came under attack. Militants seized a number of weapons before retreating into the crowd of protesters, according to the Defense Ministry. Authorities had been trying to negotiate with local officials to hand over those responsible.

Iraq’s Defense Ministry said 23 people were killed Tuesday in Hawija, including three soldiers as well as militants who were using the protest grounds as a safe haven. It said members of Al Qaeda and Hussein’s outlawed Baath Party were among the militants’ ranks.

In its account, the Defense Ministry said it warned demonstrators to leave the protest area Tuesday before moving in.

Amateur video posted on YouTube by protest supporters shows dozens of officers in riot gear and at least four anti-riot water cannon trucks facing off against a group of men. Many civilians were carrying swords, and security forces could be heard urging them to retreat.

As Iraqi forces tried to make arrests, they came under heavy fire from several types of weapons, according to the Defense Ministry account.

Officials provided details of the attacks on Sunni mosques. In Baghdad’s Dora neighborhood early Tuesday, two bombs went off near a mosque, killing seven worshippers. In the evening, a bomb exploded as people were leaving a mosque in the town of Muqdadiya, killing eight worshippers. And gunmen opened fire on worshippers leaving a mosque in northeastern Baghdad, killing three worshippers.