(BBC) -- At least 37 people have been killed after Iraqi security forces stormed a Catholic church in central Baghdad to free dozens of hostages being held by gunmen there, security sources say.
Twenty-five hostages were among the dead, along with seven members of the Iraqi security forces and at least five of the attackers, they told the BBC.
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.
Reports said the attackers were not Iraqis, but foreign Arabs.
The raid came two days after a suicide attack on a cafe in Diyala province left 21 people dead.
Residents of Baghdad's Karada district, where the attack took place, first heard a loud explosion at about 1700 (1400 GMT), followed by gunfire.
Police said a group of armed men began by attacking the Iraq Stock Exchange building, and then took over the Catholic church just across the road, clashing with guards and killing some of them.
Security forces later surrounded the church and sealed off the area, with helicopters hovering overhead. Then they stormed the building.
Witnesses nearby said they then heard two explosions from inside the church and more shooting.
One eyewitness, who was inside the church, was quoted by the AFP news agency as saying that the gunmen "came into the prayer hall and immediately killed the priest".
The witness, who declined to give his name, said the people in the church had huddled into the main prayer hall when the gunbattles began with the security forces.
The gunmen reportedly threw grenades and blew their suicide vests.
There were no negotiations with the gunmen before the security forces stormed the church, reports suggest.
Witnesses also say they saw US troops on the ground and US military helicopters hovering above the scene, but the extent of their involvement is not yet clear.
"The operation has finished and we released all the hostages," said the commander of police in south-eastern Baghdad, Brig-Gen Ali Ibrahim.
The BBC's Jim Muir in Baghdad says there are different figures from different sources for the number of hostages and attackers involved, and how many of each were killed or captured.
Earlier reports said that two security guards at the stock exchange had been killed before the attackers occupied the church.
Many churches have been bombed in recent years - including Our Lady of Salvation in August 2004 - and priests kidnapped and killed, but there has never been a prolonged hostage situation like this before, our correspondent says.
There are about 1.5 million Christians from ancient denominations in Iraq.
Iraqi Christians have been leaving the country in droves since the US-led invasion in 2003.