Baghdad (AFP) - Iraq's security forces and allied Shiite militias executed at least 255 Sunni prisoners as they fled a lightning jihadist-led advance last month, Human Rights Watch said on Friday.

"Iraqi security forces and militias affiliated with the government appear to have unlawfully executed at least 255 prisoners... since June 9," the watchdog said in a statement.

"The mass extrajudicial killings may be evidence of war crimes or crimes against humanity," the New York-based HRW said.

It said the killings appeared to have been carried out in revenge for the onslaught led by what was still known last month as the Islamic State in Iraq and the Levant (ISIL).

The group, which has since rebranded itself as the Islamic State (IS), is a Sunni extremist organisation which last month overran large swathes of Iraq, including second city Mosul, and has since declared a "caliphate" straddling the border with Syria.

"Gunning down prisoners is an outrageous violation of international law," said HRW's deputy Middle East director, Joe Stork.

"While the world rightly denounces the atrocious acts of (ISIL), it should not turn a blind eye to sectarian killing sprees by government and pro-government forces."

The rights group said it had documented massacres of prisoners last month in Mosul, as well as in the towns and villages of Tal Afar, Baquba, Jumarkhe and Rawa.

"In one case the killers also set dozens of prisoners on fire, and in two cases they threw grenades into cells," HRW said.

It demanded an international investigation into the killings.