By Isabel Coles

RFAILA, Iraq (Reuters) - The mood was festive as seven men each carried a bomb into a house on the edge of a village in northern Iraq.

Dozens of residents of Rfaila, young and old, had flocked to watch the house of their former neighbor Abu Maitham be blown up, filming the spectacle on phones to the sound of patriotic music blaring from a parked car.

They said Abu Maitham joined Islamic State militants who ruled over hundreds of towns and villages like Rfaila for more than two years, subjecting the local population to a life of violence and privation.

Abu Maitham had already fled when Iraqi forces drove the militants from the area last year as they advanced north towards Mosul, Islamic State's largest urban stronghold. The city's eastern half was cleared by January and the start of an assault on the western side was declared on Sunday.

In their wake, local people are purging every last vestige of Islamic State's presence: demolishing militants' homes and even digging up their graves.

The campaign points to a wider reckoning within Iraq's Sunni Muslim community, part of which sided with Islamic State militants who overran around one third of Iraq in 2014.

Inside the house in Rfaila, about 45 km (30 miles) south of Mosul, Ayad Jasim arranged the tubs of explosives in a circle on the floor and connected them to a wire leading out to a battery pack.

"It soothes the soul," said Jasim, as he prepared to detonate the house - his 79th since security forces regained control of the area. "There are still many left".

Jasim's motives are both patriotic and personal. His own home in another village nearby was blown up by Islamic State, and 27 members of his extended family have disappeared or been killed by the group including a 10-year-old boy.

Jasim has U.S. forces to thank for his skills: they taught him and other select soldiers how to handle explosives after invading Iraq in 2003.

As for the bombs - tubs of C4 weighing about 2 kg (4-1/2 pounds) each - they were made by Islamic State and designed to kill or maim Iraqi security forces, but have been dug up for reuse by the militants' enemies.

Story continues

The first blast destroyed only the back of the house, so two more bombs were brought to finish the job. The second explosion ripped down the rest of the building with a flash followed by a shockwave.

The audience surged towards the pile of concrete where a house had stood moments before, clambering onto the collapsed roof and firing celebratory shots into the air as the dust settled.

"PURIFYING THE LAND"

Almost everyone in the area has friends and family members who were killed by Islamic State, many of them in the security forces.

In Rfaila alone, seven officers were executed by Islamic State and several dozen policemen and soldiers were taken away, presumably to their deaths, according to residents.

Many members of the security forces who fled when Islamic State overran the area have now returned, joining government-backed Sunni militia and seeking revenge.

"This village suffered a lot," said 26-year-old resident Ammar Ibrahim, who used to be in the security forces, but is now in a Sunni militia. "They (Islamic State) blew up our houses so we are blowing up theirs. No trace of them will remain."

"Everyone cleans their own village," said another resident.

In some cases, local people have dug up the graves of Islamic State militants who were buried locally.

One resident of Rfaila described how the remains of a militant known as Abu Taha had recently been exhumed, attached to the back of a vehicle and dragged through the streets until the bones flew apart, leaving nothing behind. Several children listening to him laughed gleefully.

Photographs of the episode are posted on the Facebook page of another Rfaila resident, a member of the elite Counter Terrorism Service, urging anyone with information about other militants' grave sites to contact him "so we can purify the land from these filthy germs".

In a picture of a separate incident, the skull of another militant whose corpse was dug up in the same area sits on the bonnet of a car with a cigarette wedged between the jaw for comic effect. All but one tooth has been knocked out.

"BLOOD OF MARTYRS"

Abu Maitham was an employee of the Iraqi oil ministry before Islamic State took over, and had been involved in the insurgency against U.S. forces since 2003 along with his brother, whose house close by has also been demolished.

Residents of Rfaila said Abu Maitham and other militants from the village had left with their families as security forces closed in last year, heading north towards Mosul.

But some individuals who helped Islamic State maintain control by informing on those who broke the group's rules are still present.

Those people must go, residents said, but it is difficult to prove their guilt in a court because they did not formally swear allegiance to Islamic State, take up arms, or wear the group's uniform.

"There is no evidence so the court releases them," said Ammar Abu Rami, a brother and bodyguard of the mayor of Mosul, who is from Rfaila.

Instead, some residents are taking matters into their own hands, throwing grenades at the homes of people they accuse of supporting Islamic State. "They don't kill them: just frighten them," Abu Rami said.

Another resident said: "Their (the state's) procedures are slow and emotions are high. They (the authorities) say wait a bit, but people can't."

Abu Maitham's house had already been torched from the inside before it was blown up. Scratched onto the charred wall of one room that would soon cease to exist were the words: "No bargaining with the blood of our martyrs. The time for dialogue is over."

(editing by David Stamp)