Gunmen in four-wheel drive vehicles attacked two buildings in a housing complex in Baghdad’s Zayounah neighbourhood, killing at least 33 people including 29 women, police said.
At least 18 people were wounded in the attack in the mixed Shia-Sunni area, although the motive behind it is unclear.
Police said there are suspicions the buildings were being used as a brothel.
The words “This is the punishment of those practising prostitution” were scrawled in black on one of the buildings, according to a police officer who spoke to Reuters.
Locals have accused Shi’ite militias of carrying out killings of women branded as prostitutes in the same district of Baghdad.
The attack came as Sunni militants controlling large parts of northern Iraq attacked a town north of Baghdad, seizing local government buildings.
Militants in 50 to 60 vehicles stormed the town of Dhuluiya, about 45 miles north of Baghdad, and took the mayor’s office and municipal council building and fought to take control of the police station.
Local police and tribes were fighting against the militants in Dhuluiya, and four policemen were killed in the fighting along with two militants and two civlians, said police.
Insurgents also bombed a bridge linking Dhuluiya to the nearby Shi’ite town of Balad to the west, police said.
Parliamentarians are preparing to meet to attempt new progress progress on agreeing a new prime minister, president and parliamentary speaker, three months after a parliamentary election.
Iraq’s political elite are under pressure from the US, the United Nations and Iraq’s own Shi’ite clerics to reach agreement so that politicans can try to prevent the country from fracturing on sectarian and ethinc lines.
It is unclear which militant group carried out the attack.