An instructor teaching his militant recruits how to make car bombs accidentally set off explosives in his demonstration Monday, killing 21 of them in a huge blast that alerted authorities to the existence of the rural training camp in an orchard north of Baghdad. Nearly two dozen people were arrested, including wounded insurgents trying to hobble away from the scene.

The fatal goof by the al-Qaida breakaway group that dominates the Sunni Muslim insurgency in Iraq happened on the same day that the speaker of the Iraqi parliament, a prominent Sunni whom the militants consider a traitor, escaped unhurt from a roadside bomb attack on his motorcade in the northern city of Mosul.

The events underscored the determination of the insurgents to regain the strength they enjoyed in Iraq until U.S.-backed Sunni tribesmen turned against them at the height of the war. The militants are currently battling for control of mainly Sunni areas of western Iraq in a key test of the Shiite-led government’s ability to maintain security more than two years after the withdrawal of U.S. troops.

While the Iraqi army has been attacking insurgent training camps in the vast desert of western Anbar province near the Syrian border, it is unusual to find such a camp in the center of the country, just 60 miles north of the capital.

The discovery shows that “the terrorist groups have made a strong comeback in Iraq and that the security problems are far from over, and things are heading from bad to worse,” said Hamid al-Mutlaq, a member of the parliament’s security and defense committee.

The militants belonged to a network now known as the Islamic State of Iraq and the Levant, an extremist group that recently broke with al-Qaida. The ISIL, emboldened by fellow fighters’ gains in the Syrian civil war, has tried to position itself as the champion of Iraqi Sunnis angry at the government over what they see as efforts to marginalize them.

Car bombs are one of the deadliest weapons used by thw group, with coordinated waves of explosions regularly leaving scores dead in Baghdad and elsewhere across the country. The bombs are sometimes assembled in farm compounds where militants can gather without being spotted, or in car workshops in industrial areas.

The explosion Monday took place at a camp tucked away in an orchard in the village of al-Jalam, a farming area that has been a stronghold of al-Qaida close to the Sunni city of Samarra. According to a police officer, an army official and a hospital official, all of whom spoke on condition of anonymity for security reasons, the militants were attending a lesson on making car bombs and explosive belts when a glitch set off one of the devices during the car bomb part of the demonstration.

Security forces rushed to the area after hearing the thunderous blast and arrested 12 wounded militants along with another 10 trying to flee. Authorities searched two houses and a garage in the orchard, finding seven car bombs as well as several explosive belts and roadside bombs. Bomb experts then started the work of defusing the devices.

Violence has spiked in Iraq since last April, when security forces cracked down on a Sunni protest camp north of Baghdad in clashes that left 45 dead.

The situation deteriorated significantly in late December, when security forces dismantled a protest camp near the Anbar provincial capital of Ramadi. To defuse the tension, the security forces withdrew from Ramadi and the nearby city of Fallujah. ISIL militants promptly took over parts of Ramadi and the center of Fallujah.