"It was carnage," said Monsignor Pius Kasha, whose Syriac Catholic church was targeted by the militants. Witnesses said the assailants were armed with automatic rifles and suicide belts.
"There were less than 80 people inside the church, and only 10 to 12 escaped unhurt," Kasha said, adding that two priests were among the dead and that 25 worshippers were wounded. One priest was shot in the kidney.
An interior ministry official said 46 worshippers were killed and 60 wounded. He said more than 100 people were inside the church at the time of the attack.
Seven security members also died, the official said, adding that five attackers were killed.
"It was a quick and successful operation," said Defence Minister Abdul Qader Obeidi.
Prime Minister Nuri al-Maliki condemned the "cowardly crime," blaming it on "Al-Qaeda and remnants of the former regime seeking to destabilise Iraq, revive confessional differences and spur Iraqis to flee their country."
A witness said that immediately on entering the Sayidat al-Nejat Syriac Christian cathedral during evening mass on Sunday, the gunmen shot dead a priest while worshippers huddled in fear.
"They entered the church with their weapons, wearing military uniforms. They came into the prayer hall, and immediately killed the priest," said one of the freed hostages, an 18-year-old man who declined to be named.
"We heard a lot of gunfire and explosions, and some people were hurt from falling windows, doors and debris."
Iraqi officials said that at least one of the gunmen had blown himself up with a suicide belt as police made a first attempt to enter the church.
Traces of flesh, blood, bullet marks and shattered glass littered the cathedral, an AFP journalist reported.
American soldiers dressed in combat gear also took part in the assault, some witnesses said, an assertion denied by the US military and the Iraqis.
"The (Iraqi) anti-terror forces are the only forces who raided the church, there were no Americans at all," Samer al-Shuaili, spokesman for Iraq's anti-terror unit, told AFP.
The US military said it had "advisers" near the scene, but that none of its soldiers were involved in the assault.
"There were no US soldiers involved in the assault to free the hostages," spokesman Colonel Barry Johnson said.
Baghdad's Chaldean bishop, Shlimoune Wardouni, said the gunmen were demanding the release of detainees held in Iraq and Egypt.
The SITE monitoring group said the Islamic State of Iraq, the local Al-Qaeda front organisation, had claimed the attack and had given Egypt's Coptic church a 48-hour deadline to release women it said were being held captive.
SITE said the threat came amid calls by jihadists and Al-Qaeda's media arm for Muslims to take action against the Coptic church over the alleged imprisonment of the two women, both wives of Coptic priests.
Egypt refused to react to the demands.
"Egypt categorically rejects having its name or affairs pushed into such criminal acts," the foreign ministry said in a statement issued in Cairo.
Condemnations poured in from around the world. Pope Benedict XVI branded the attack an act of "absurd and ferocious violence."
Washington said the attack was "particularly reprehensible," while European Union foreign affairs chief Catherine Ashton said she was "deeply saddened".
Before the US-led invasion of 2003, around 800,000 Christians lived in Iraq but that number has since shrunk to 550,000 in the face of repeated attacks against the community and its places of worship.
Nationwide, violence has abated in Iraq since its peak in 2006-2007, but attacks are still frequent in the capital Baghdad and the main northern city Mosul.