BAGHDAD — Iraq's government suffered an embarrassment Wednesday after a rare move to limit impunity among Iran-linked militias instead resulted in a commander accused of several killings walking free from custody and into a hero's welcome.

Although Prime Minister Mustafa al-Kadhimi’s government issued no statement about the May 26 arrest of Qasim Musleh, a militia commander from the southern city of Karbala, the fallout from it has dominated news broadcasts and underscored the administration’s weakness as militias kill and intimidate members of a protest movement that brought Kadhimi to power.

The arrest had sparked immediate controversy. Iran-linked militiamen arrived at the gates of Baghdad’s heavily fortified Green Zone within hours. The army was deployed. That standoff ended only when one of Kadhimi’s predecessors and political foes, Nouri al-Maliki, stepped in to defuse tensions, officials say.

In a statement Wednesday, Iraq’s judiciary said that it had not seen sufficient evidence to convict Musleh and that he had provided a document showing that he was out of the country during the killing of at least one of two civil society activists in Karbala whose deaths he is being linked to. Iraqi officials had previously said that they had a case file proving his connection to the killing.

Kadhimi’s government is under pressure from U.S. officials to rein in Iran-linked groups that have attacked American troops. But Musleh’s case provides a stark lesson in how power works in Iraq, experts say. Although Kadhimi is the commander in chief, a handful of influential militias, some linked to Iran, often hold the upper hand in practice. Although the prime minister makes frequent promises to bring the killers of activists to justice, he has done little to achieve it, analysts say, fearing blowback.

Throughout Musleh’s detention, his location was shrouded in secrecy, with the government unable to definitively prove that it had him in custody. Rumors swirled that he had been moved to the house of Faleh al-Fayyadh, leader of the Popular Mobilization Forces militia network, as backroom deals for Musleh’s release were worked out.

By Monday, the case file was being handled by a judge associated with the Popular Mobilization Forces, according to judicial officials. On Wednesday, Musleh was released.

Photographs from a bridge across the Tigris River in Baghdad show the militiaman’s supporters hugging and kissing him after his release. Hours later, he was receiving a rapturous welcome in Karbala.

The government did not issue any statement acknowledging the release.

Hundreds of activists, journalists and militia critics have been killed since mass protests swept Iraq in October 2019. Only a handful of people have been arrested in those killings, and none are known to have been prosecuted.

“It’s worrying that Musleh’s initial arrest was so difficult to secure and that the government came under so much pressure,” said Sajad Jiyad, a fellow with the U.S.-based Century Foundation think tank. “He wasn’t the most senior person, and yet even then they couldn’t make the charges stick.”

The demonstrations had initially seemed to weaken long-standing taboos against criticism of militias linked to Tehran. Protesters hurled their shoes at images of powerful militia commanders and burned the headquarters of armed groups.

But the demonstrations were quashed with deadly force, and a rising tide of killings, abductions and threats by the militias has since cast a fresh pall of fear over civil society. According to the United Nations, parents seeking justice for slain children have been intimidated into dropping cases. In March, the father of a missing activist was fatally shot in the street.

Musleh’s arrest followed protests across Baghdad and Iraq’s southern cities demanding that the government hold the killers accountable. In media interviews, the mother of Ehab al-Wazni, an activist killed outside his home in Karbala last month, accused Musleh by name. “He told him: ‘I will kill you, even if it’s the last day of my life,’ ” she said. “When he left the house, there would be a car or motorcycle following him.”

Days later, she told another Iraqi television channel that no senior officials had contacted her in connection with the Musleh inquiry or to communicate any aspect of an investigation announced by Kadhimi of her son’s case.

“This mother wants to see a result. Whether Musleh ordered the murder or not, for her, there’s no process. No one reached out to her,” Jiyad said.

“There’s no accountability. These families are still waiting.”