At least 31 people died when gunmen burst into two apartments being used as a brothel in the Iraqi capital.

Security sources said 28 of the dead were women. Two men appeared to have had their hands tied behind their backs before being shot dead.

The attack occurred in the Zayouna district on Saturday evening.

Photographs taken after the killings showed the bodies of five women in a corner of a bathroom with blood-spattered tiled walls and floor, in what seemed to have been a desperate attempt to hide from their attackers.

Another shows bodies, some wearing bright colours, others dressed in black, lined up in a living room, the floor of which was covered with blood.

Access to the only street leading to buildings where the killings took place, is usually overseen by police and soldiers.

"This is the fate of any prostitution," read an inscription on the front door of one of the raided buildings.

Such raids are not uncommon in Zayouna, but Saturday's was the deadliest in years.

It is not clear who the killers were.

Most residents were afraid to speak, with religious militiamen having become even more prominent in Baghdad since a jihadist-led onslaught launched last month exacerbated sectarian tension.