BAGHDAD — A leading Iraqi researcher, Hisham al-Hashimi, was fatally shot late Monday outside his house in Baghdad, officials said.

The gunmen had waited outside his home on a motorcycle, one security official said, speaking on the condition of anonymity because he was not authorized to speak with the media. The assailants then fled the scene, he said.

No group claimed responsibility for the killing, but for many in Iraq, it underscored the reality of a slow-burn assassination campaign by militia groups against their critics. Hashimi, 47, was a frequent target of the propaganda of Iran-backed militia groups, and friends and colleagues said he had faced a rising tide of threats.

The researcher was among the world’s leading experts on the Islamic State group, providing details of its inner workings to the international media and advising the Iraqi government on its response. More recently, he had spoken out about the impunity with which Iran-backed militias now operate in Iraq.

Iraq’s new prime minister, Mustafa al-Kadhimi, blamed Hashimi’s killing on armed groups “outside of the law,” vowing in a statement to “hunt” and prosecute them. Late Monday, the U.S. Embassy in Baghdad urged Kadhimi to make good on his promise. “We call on the Iraqi government to bring those responsible for his murder to swift justice,” it said in a post on Facebook.

Hashimi’s death sparked an outpouring of grief across television and social media channels. “Watching colleagues of Dr. Hisham burst into tears as they try to comment on his assassination is telling of who he was,” said Lahib Higel, Crisis Group’s senior analyst for Iraq. “Every time I met him he encouraged me to do more, seek out new opportunities to serve. I don’t know how he made time for everyone.”

Although Iran-linked militias are powerful here, their movement has suffered a string of setbacks since the end of last year, including the death of their leader, Abu Mahdi al-Muhandis, in a U.S. drone strike that also killed Iranian commander Qasem Soleimani in January.

Kadhimi has vowed to end militia attacks on U.S. and other Western military and diplomatic facilities, in contrast to his predecessor, Adel Abdul Mahdi, who was unable, or unwilling, to take on the armed groups.

For a period in November, when Abdul Mahdi was still in power and mass protests decried the influence of Iran-backed militias, Hashimi disappeared from the airwaves, telling acquaintances he had been threatened by the Kataib Hezbollah group. More recently, he had become more vocal and with every passing month, friends said, more at risk.

When Kadhimi ordered an unprecedented raid on Kataib Hezbollah operatives last week, citing evidence that they were planning fresh attacks, Hashimi was among the first to share full details on social media. Responses to his post included threats from militia supporters saying that he instead deserved arrest.

All but one of the militiamen were released shortly afterward. Rocket attacks have resumed. Kadhimi, experts say, will now face an uphill battle in reining them in.

In a Facebook post Sunday, Hashimi said the recent change in Iraq’s political leadership had affected the Iran-linked movement’s power in Iraq. Their recent attacks, he wrote, were motivated by “revenge, absurdity and delusion.”

Loveluck reported from London.