"The total number of dead now stands at 31, two of them men," interior ministry spokesman Saad Maan told AFP.
Gunmen stormed two buildings in Baghdad's residential district of Zayouna, known in the area for housing rented flats where a notorious pimp kept a "stable" of up to 60 women.
Photographs taken soon after the killings on Saturday evening showed a man, identified by police sources as the pimp, lying dead in a pool of blood alongside one of his presumed henchmen.
Another picture shows the crouching bodies of five women huddled together 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.
Also Read
Another shows bodies, some wearing bright colours, others dressed in black, lined up in a living room, the floor of which was drenched with blood.
Access to the only street leading to buildings 43 and 44, 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 punitive raids are not uncommon in Zayouna, but Saturday's was the deadliest in years.
It was not immediately 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 tensions and pushed Iraq to the brink of disintegration.