The Islamic State group is conducting a purge, killing dozens of former policemen and soldiers living in areas of Iraq under its control, in a campaign apparently aimed at preventing any uprising against its extremist rule.

Former officers have been gunned down in their homes, rounded up and shot in groups or killed in public squares as an example to others in recent weeks, particularly in the northern city of Mosul, the largest city in the swath of territory bridging Iraq and neighboring Syria that the militant group controls.

The campaign appears aimed at shoring up the extremists' hold at a time when theu are being hit by the U.S.-led international air campaign and have lost some ground to Kurdish fighters and Shiite militias.

In one recent killing, Islamic State group gunmen last week stormed the home of former police Col. Mohammed Hassan, in Mosul. Hassan and his son fought back, killing three attackers before they were gunned down.

The militants then hung his mutilated body from a fence for several days near his home as an example, according to two residents who witnessed the battle and were aware of the events leading up to it. They spoke to The Associated Press on condition of anonymity for fear of reprisals.

Hassan was among some Sunnis in the security forces who surrendered, handed over their weapons and pledged to cut ties with the police when the Islamic State group overran Mosul in June. In return, the militants gave them "repentance badges" granting them some safety. But now, the Islamic State group suspected Hassan was engaging in activities against it.

The campaign of killings adds a new bloody chapter in the Islamic State group's legacy. In its blitz capturing a swath of Iraq and neighboring Syria, it gained a grisly notoriety for butchering its opponents and members of sects it considers heretical.

Human Rights Watch on Thursday said that the extremists carried out a mass killing of around 600 Shiite Muslim inmates being held in Mosul's main prison when the group captured the city in June. The Shiites were separated from several hundred Sunni and Christian inmates who were set free, then the Shiites — along with a number of Kurds and Yazidis — were forced to kneel on the edge of a nearby ravine and were mowed down with automatic weapons, Human Rights Watch said in a report, based on interviews with survivors.

But killings of former police are of a new, different sort — a campaign to eliminate those who the extremists fear could become the nucleus of a revolt against their control.

In new killings, the militants on Wednesday paraded 30 Sunni tribal fighters through the western city of Hit then shot them all to death on a main street, according to a provincial official and other residents. Their bodies were found later that day, followed by another mass grave of 48 tribal fighters discovered on Thursday. The fighters, mostly from the Al Bu Nimr tribe, were captured when the extremists overran Hit earlier in the month.

Mosul, the largest city in the group's self-styled "caliphate," has seen increased killings. Last week, Mosul's governor, Atheel al-Nujaifi, who was driven out of the city in the militant takeover, said pro-government Sunni militias were being formed in the city, made up of mainly of former army and police officers.

Soon after, Islamic State group militants rounded up 20 former police officers from villages south of Mosul. Hours later, their bodies — all with gunshots to the head — were handed over to the morgue, according to morgue officials, who spoke on condition of anonymity for fear of retaliation.

In a separate incident, the militants shot to death police Col. Issa Osman after parading him through Mosul's streets. Osman's battalion was the last unit to give up fighting in Mosul during the June takeover, and afterward he also renounced ties to the security forces, receiving a "repentance badge" from the extremists.

Military spokesman Brig. Gen. Saad Maan Ibrahim also said anti-ISIS militant groups have been formed in Mosul. Whether they are part of armed groups or not, former police and army officers are a potential threat to the militants because they "have the expertise on how to plan an armed uprising and they have good knowledge of weapons and military operation," Maan told AP.

There have been similar slayings elsewhere under the extremists' domain the past week. Three days ago, IS fighters shot to death two former army officers and three policemen in a public square in the northern city of Beiji, residents said. They announced to a crowd that the men had carried out mortar attacks on the militants' positions in the city, according to the residents.

At the same time, about 20 former policemen and army officers were rounded up by IS fighters in the town of Shurqat and taken to an unknown location, with no word since on their fate, said an official in Salahuddin provincial council.

On Wednesday, ISIS fighters beheaded policeman Bahjat Salman in a public square in Ana, a town west of Bagdad, proclaiming him a "traitor," residents said. The residents of Ana and Beiji and the Salahuddin official spoke to AP on condition of anonymity for their own safety.

So far, there has been little sign of an armed revolt in Mosul or other parts of northern and western Iraq under ISIS control. But the killings could be a sign the extremists' confidence has been shaken by the air campaign.

The group was able to expand with lightning speed across Sunni-dominated regions of Iraq starting in June, in large part because of the minority community's deep hatred of the Shiite-dominated government in Baghdad. Sunnis have long complained the government discriminates against them and marginalizes them. Government forces collapsed as the extremists swept over Mosul, then south toward the capital, capturing towns and cities along the way.

But there has been resentment among some Mosul residents fueled by the group's enforcement of its extremist interpretation of Islamic law, a lack of public services and stagnation in business.

"Most Mosul people want to get rid of this savage organization," said a resident speaking on condition of anonymity for fear of reprisals. "We are waiting for any effort to save us."