JURF AL-SAKHAR Iraq (Reuters) - After helping government forces break Islamic State's grip over a strategic town just south of Baghdad on Saturday, Shi'ite militias decided it was time for payback.

A Reuters witness saw the fighters in green camouflage uniforms scream and swear at members of the Islamist group as they kicked and struck them with rifle butts in Jurf al-Sakhar.

As the angry crowd of militiamen around the unarmed militants swelled, shots rang out. The three men lay soaked in blood in the dirt with gunshot wounds to the head.

"Those dogs are Chechens. They don't deserve to stay alive. We took confessions from them and we don't need them anymore," said one of the Shi'ite militiamen.

The victory could allow Iraqi forces to prevent the Sunni insurgents from edging closer to the capital, sever connections to their strongholds in western Anbar province and stop them infiltrating the mainly Shi'ite Muslim south.

Asked why the three men were executed, an army officer in Jurf al-Sakhar said: "We don't need them anymore. Why should we keep them alive?"

Responding to the same question, a senior member of a local Shi'ite militia said: "When we liberated Jurf al-Sakhar we found the skeletons of innocent people they killed and never buried. They should face the same fate."

Islamic State, made up of Arab and foreign fighters, swept through the north of Iraq in June and controls large parts of the west as well.

Its fighters hold swathes of territory in neighboring Syria and the group seeks to create an Islamic caliphate in the heart of the Middle East.

The group has threatened to march on Baghdad, home to special forces and thousands of Shi'ite militias expected to put up fierce resistance if the capital comes under threat.

Jurf al-Sakhar looked like a ghost town. Many residents had fled the fighting. Islamic State fighters had for months used skilled snipers and roadside bombs to prevent Iraqi security forces and Shi'ite militias from advancing.

Story continues

During that period Islamic State used secret tunnels built by Saddam Hussein to evade United Nations weapons inspectors to move and store weapons and supplies.

Iraqi forces brought in helicopter gunships and used rockets to build up pressure on the militants, who finally fled on Saturday.

DEAD SNIPER DANGLES FROM TREETOP

There were rows of abandoned houses in Jurf al-Sakhar, some still burning. Black smoke hung over the town, surrounded by farmland, irrigation canals and swamps which had made it difficult for Iraqi forces to make headway.

An Islamic State sniper who had attached himself with a rope to the top a date tree was slumped over and swinging back and forth after being hit by machinegun fire from a helicopter.

"This terrorist stopped us from making advances for the whole day and killed a lot of us," said another militia fighter who also asked not to be named, pointing to the insurgent's rifle on the ground.

"We could not stop him, only a helicopter could."

The bodies of more than 50 Islamic State fighters were scattered across Jurf al-Sakhar, on streets, in trenches, near houses and on the beds of pickup trucks, many of them charred.

The dead included 15 militants whose hands were tied behind their backs, lying in farmland.

The stench of death was everywhere as flies covered bodies.

Asked why government forces had not buried the bodies of men who were killed a day before, an Iraqi army colonel said: "Those terrorists do not deserve to be buried. Let the dogs eat their flesh. Many of our men were killed by them."

But then came a reminder of the determination of Islamic State militants to expand their reach to Baghdad in pursuit of a powerful caliphate.

As Iraqi government soldiers and militias savored their victory and were taking photographs of the bodies, mortars fired by Islamic State fighters who had fled to orchards to the west rained down on the town.

The blast hit the militiamen, killing dozens and scattering body parts. Soldiers who moments before were celebrating now screamed out in fear.

"Run to the ditch. Mortars. Mortars," yelled a militiaman. An army officer shouted at local militia leaders, berating them for advancing too fast, before helicopters had wiped out any pockets of resistance.

"OK, let's retreat," one of the militiamen shouted.

(Writing by Ahmed Rasheed and Michael Georgy; Editing by Rosalind Russell)