As security forces stormed a Catholic church in Baghdad (map, from aljazeera.net) to free dozens of hostages, at least 52 people died, said Deputy Interior Minister Maj Gen Hussein Kamal.
He suggested six attackers had also died in the fighting, though other sources have said the overall death toll was lower.
About 100 people had been inside Our Lady of Salvation for an evening Mass.
The gunmen had reportedly demanded the release of jailed al-Qaeda militants.
The local TV station, al-Baghdadiya, said it had received a phone call from someone claiming to be one of the attackers, who said they were from the Islamic State of Iraq, a Sunni militant umbrella group to which al-Qaeda in Iraq belongs.
According to reports the attackers were not Iraqis, but foreign Arabs.
‘Immediately killed the priest’
The attack took place at Baghdad’s Karada district. Residents there first heard a loud explosion at about 17:00 (14:00 GMT) on Sunday, followed by gunfire.
According to the police, a group of armed men first attacked the Iraq Stock Exchange building, before taking over the Catholic church just across the road, clashing with guards and killing some of them.
One eyewitness, who was inside the church, said the gunmen “came into the prayer hall and immediately killed the priest”. The witness, who refused to give his name, said worshippers were beaten and herded into an inner hall.
Then there was a long stand-off as security forces surrounded the building with helicopters hovering overhead.
By mobile phone, the militants demanded the release of al-Qaeda prisoners, and of a number of Muslim women who they insisted were being held prisoner by the Coptic Church in Egypt.
As the discussions got nowhere, the security forces stormed the church.
Witnesses nearby said they then heard two explosions from inside the church and more shooting.
The gunmen reportedly threw grenades and detonated their suicide vests.
Although a police source earlier said 37 people (worshippers, security forces and attackers) had been killed, Maj Gen Hussein Kamal said 52 “martyrs” had died in the fighting, along with six attackers.
The same police source also said 56 people had been wounded.
The Iraqi defence minister, Abdul-Qadr al-Obeidi, said: “We took a decision to launch a land offensive, and in addition an airdrop, because it was impossible to wait – the terrorists were planning to kill a large number of our brothers, the Christians who were at Mass.
“So the operation was successfully done. All terrorists were killed. And we now have other suspects in detention.”
Though the extent of US involvment is still unclear, witnesses say they saw US troops on the ground and US military helicopters hovering above the scene.
In recent years priests have been kidnapped and killed, and many churches have been bombed in Iraq, including Our Lady of Salvation in August 2004.
Iraq holds about half a million Christians from ancient denominations in Iraq. But since US-led invasion in 2003, Iraqi Christians have been leaving the country in droves.