Andrea Bruce Woodall/The Washington Post

BAGHDAD, Iraq — If the gunmen who carried out a mass killing Saturday night escape punishment it will be not only because the victims were prostitutes, all too often friendless and forgotten, but also because the government needs to keep the murderers on its side.

Officially, Iraq’s Ministry of the Interior is still investigating the crime, but many Iraqis believe it’s clear who is responsible. They say the killing was carried out by members of a local Shia militia, religious extremists whose armed members both cooperate and compete with the government for control of the area where the killing occurred.

WARNING: GRAPHIC PHOTOBELOW

Twenty-nine women, reported to be prostitutes, were executed inside the apartment where they worked in the Zayouna neighborhood on Baghdad’s east side. Two men also were found dead inside, one of them the reported pimp. Many of those killed had gunshot wounds to the head. Police found one woman’s body inside a cupboard where she had tried to hide. Photographs of the gruesome spectacle have circulated widely on the Internet.

Written on the door of the building was the warning: “This is the fate of any prostitution.” The carnage and the inscription are read by Iraqis as a militia’s show of power, declaring authority in the area, and warning locals that what the militia deem moral crimes can be punished with summary execution.

No one will name the group responsible for the slaughter but privately Iraqis say that it was likely carried out by Asaib Ahl al-Haq, an Iranian-backed Shia militia group that operates openly in Zayouna. There is no proof that it is responsible for the killing Saturday, but few Iraqis doubt that it is capable of such violence.

Asaib Ahl al-Haq, which means “League of the Righteous,” began as an arm of the Mahdi Army, Iraq’s largest Shia militia led by the militant religious leader Muqtada al-Sadr, but it split from the group in 2008. Since the U.S. military’s withdrawal in 2011, Asaib Ahl al-Haq has become a powerful force in Iraq, with a small but dangerous army of devoted fighters and influence inside the national government. In neighborhoods like Zayouna, Iraqis live under the authority and at the whim of such men. And few are more vulnerable than women sex workers.

“Everyone knew it was prostitutes there; the militia killed them,” said one Iraqi vendor selling water on the street only a block from where the massacre took place. He could or would not say what militia was responsible for the crime and asked not to be identified out of fear for his safety. “The same ones who killed them used to visit,” the vendor said. How he would know this is unclear, but it’s a common view of what happened.

Qain Zuhair, a teacher who has worked with many young Iraqis, also believes that a militia was responsible for the killing and that the group’s morality police take a selective approach to enforcement. “They are conflicted,” he said. “The same men who killed the prostitutes also went to visit them. They love the prostitutes, then they kill them.”

Similar murders have taken place in Zayouna in the past. Two separate shootings killed 15 people, among them several prostitutes, in May 2013. Stores selling alcohol, which is legal in Iraq but forbidden under Islamic law, also have been targets of violence in the area.

Hanaa Edwar, head of the Iraqi Al-Amal Association, an NGO in Baghdad, suggests this was not only a heinous crime but also a challenge to the government’s already weak ability to set and uphold the law. “The militias try to replace the rule of the law,” she said. “The armed groups are trying to replace the security forces. This is a horrible thing for the country.”

Across Baghdad, militias operate as local authorities both alongside official forces and independent of the government’s reach. On the city’s streets and highways, bearded militia members in irregular uniforms and black SUVs travel in convoys mixed in with Iraqi soldiers driving Humvees. They move throughout the city.

Historically, militias have had a contentious and sometimes hostile relationship with the Baghdad government—battling against it in some areas while sharing power in others. But in Iraq’s latest war against the ferocious Sunni jihadists known by the acronym ISIS, or Islamic State, hostilities among Shia gunmen and the government have given way to alliances of necessity.

ISIS and its predecessor, Al Qaeda in Iraq, have slaughtered Shia Iraqis, blown up their mosques and shrines and done everything they can to encourage open sectarian violence. This in turn has fueled the growth of Shia militias that have pledged to defend their people from such attacks and protect the interests of their groups, even as they demand obeisance.

After Iraq’s American-trained army crumbled in the north of the country last month and ISIS started rolling toward the capital, both the Iraqi government and the Shia militias in Baghdad sought to counter the advance.

The government of Prime Minister Nouri al-Maliki called for volunteers to replace the ranks of its military hollowed out by mass desertion, and now relies heavily on the Shia militias. “Their power has increased as the crisis has worsened,” says Zuhair. As a result, even a mass murder carried out by militias inside Baghdad is unlikely to disrupt the alliance against ISIS.

The government has promised to investigate, but Hanaa Edwar doesn’t believe it. This is a country at war. Atrocities have become common, and the government’s ability and willingness to bring justice in the courts is rare. The police are investigating? “They always say this,” she says. “It’s just: blah blah blah. After they say this, it’s forgotten.”