Baghdad (CNN) -- An Iraqi prisoner grabbed a police officer's gun while being moved from a detention cell Sunday and opened fire, triggering a gunbattle between prisoners and police officers that lasted for hours and left 17 people dead, a military spokesman said.
The victims included six police officers, said Gen. Qassim Atta of Baghdad Operations Command. Several others were wounded, including another suspect in the church siege, Iraqi interior ministry officials said.
The shooter, identified as Huthaifa al-Batawi, managed to free other insurgents and hand them the dead police officers' weapons. He was then killed in a gunfight, officials said.
Iraqi officials describe al-Batawi as the leader of the Islamic State of Iraq and the "mastermind, direct supervisor and planner" of the October 2010 siege at Our Lady of Salvation Church that left more than 70 people dead and 75 more wounded.
He was handcuffed and was being moved from a detention cell inside the interior ministry compound to an office where he was to be questioned in the investigation when he grabbed the gun, the ministry said.
Interior Ministry officials say insurgents tried to flee the compound but were repelled by police.
Months earlier, Al-Batawi had tried to commit suicide using an electrical cable from a wall, officials said.
Interior ministry officials said al-Batawi confessed to his role in the church siege after his November 2010 arrest. He told Iraqi authorities he was the leader of the Islamic State of Iraq, an umbrella group that includes a number of Sunni extremist organizations and has ties to al Qaeda in Iraq. The Islamic State of Iraq claimed responsibility for the Baghdad church siege.
As many as 120 people were taken hostage inside the church. Gunmen held them for hours before security forces stormed in to end the standoff, arresting eight suspects.
Most of the hostages were killed or wounded when the attackers set off explosives inside the church, defense ministry officials said at the time.
Al-Batawi and the other gunmen were demanding that the Iraqi government release a number of prisoners, saying the Christian hostages would be freed in return, according to officials at the time.
The insurgents killed Sunday were involved in the church attack in October, according to Ahmed Abu Ragheef, Director of Internal Affairs at Iraq's Ministry of Interior.
The men were also involved in assasination attempts and other attacks, including last year's attacks on Baghdad's Central Bank which left more than two dozen people dead, officials said.