Shiite militiamen stand by a destroyed bridge Tuesday in Jurf al-Sakhar, an Iraqi town southwest of Baghdad that has been the scene of clashes for months. (Loveday Morris/The Washington Post)

Iraq renamed this town on the banks of the Euphrates this week to reflect the triumph of its security forces here against Islamic State militants, who were driven out last week. Jurf al-Sakhar, or “rocky bank,” became Jurf al-Nasr, or “victory bank.”

But a visit to the Sunni settlement Tuesday laid bare the huge cost of that victory. The town is now emptied of its 80,000 residents, and building after building has been destroyed — by airstrikes, bombings and artillery fire.

After four months of battles between the Islamic State and the Iraqi army, about 10,000 pro-government Shiite militiamen were poured into this area in Babil province for a final push, according to Hadi al-Amiri, who leads the Iranian-backed Badr Brigade and coordinated the operation. Defeating the militants involved clearing out all of the residents and leaving the town nearly flattened, underscoring the challenge the Shiite-led government faces in areas where demographics do not work in its favor.

Here, there was no choice but to push forward. In just over a month, the nearby highway would be packed with millions of Shiite pilgrims heading south to commemorate the death of Imam Hussein, a figure revered in Shiite Islam. Militants based in Jurf al-Sakhar had stepped up attacks in recent weeks on the holy city of Karbala, about 20 miles south and home to the Imam Hussein shrine. Officials said clearing Jurf al-Sakhar of militants had been essential to prevent large-scale assaults during more than a month of religious events.

On Tuesday, hundreds of militiamen trundled out of Jurf al-Sakhar in trucks and buses, handing over control of the town and outlying villages and farms to Iraqi security forces. As flatbed trucks carrying field artillery waited to move out, Humvees and bomb-disposal vehicles burned in streets that the insurgents had laced with explosives. In the town center, the smell of death lingered in the air.

The Shiite forces could not remain in the area, militia commanders said. Their presence would only spark controversy and accusations of sectarian killings, they said. There already have been reports of revenge attacks in the aftermath of the Jurf al-Sakhar victory.

It was not hard to see why such reports were circulating. A convoy of trucks blaring religious music from loudspeakers drove out on a dusty road just north of the town. The men in the truck were jovial and flashed peace signs, but the decaying body of an alleged insurgent was being dragged behind the vehicle. A commander with the militiamen, newly recruited volunteers who joined under a religious appeal to take up arms in June, became angry about the body being photographed.

“They are worried that it looks bad that we are killing them,” said a Badr commander who gave his name as Abu Muslim. “But they killed us at Speicher, so we should be able to kill them,” he added, referring to what Iraqi officials allege was the execution of 700 soldiers at the Camp Speicher base in northern Iraq in June by Islamic State militants.

Militiamen expressed concern that the regular security forces would not be able to hold the area by themselves. The Iraqi army has been plagued by desertions and corruption, collapsing in the face of the Islamic State’s initial advance in June. Amiri said that despite pleas from the army for the “public mobilization” — as the militias and Shiite volunteers are collectively known — to assist in the neighboring Sunni province of Anbar, major operations there could spark sectarian friction.

But this operation was of particular religious significance, and Iran, Iraq’s Shiite neighbor and ally, is alleged to have played a major role in clearing Jurf al-Sakhar. Pictures circulating online showed Amiri on the battlefield with Qassem Soleimani, the leader of Iran’s elite Quds Force.

“I swear he’s not here today,” Amiri said, smirking when asked whether the Iranian commander had been at the scene in the days prior.

A local police officer, who spoke on the condition of anonymity because he is not authorized to talk to the media, said Iranian fighters were present on the battlefield, while a Washington Post employee heard Farsi being spoken at a military base.

Iraqi Shiite militiamen drag the body of an alleged insurgent along a street in Jurf al-Sakhar. (Loveday Morris/The Washington Post)

“There were no Iranian forces, but if there was a presence of some individuals, it was all officially coordinated,” said Sheik Qassim Sudani, a commander with Kataib Hezbollah, another Iranian-backed militia that is fighting in the area.

Jurf al-Sakhar has long been linked to extremism, becoming a stronghold of the insurgency in the years after the 2003 U.S.-led invasion of Iraq.

Local officials say those days are over. But the future of the town is unclear. None of its Sunni residents remain or are likely to return anytime soon. Those who had stayed in the town until last week were considered combatants, said Hassan Shakir Oda, a member of the provincial council and the Badr Brigade.

“We considered every family that stayed al-Qaeda or Daesh,” he said, referring to the Islamic State by its Arabic acronym. “If anyone against Daesh had stayed, Daesh would have killed them.”

The operation in Jurf al-Sakhar has “broken the back” of the Islamic State and proved that the group can be taken on in Anbar, just a few miles to the west, Oda argued.

But such an endeavor may exact just as high a toll, or greater. Jurf al-Sakhar has been left a shell of its former self — deserted and virtually uninhabitable.

Allowing those who left to return would run the risk of letting insurgents sneak in with them, Oda said. He also said that there is no electricity and that the town is unsafe.

“For now, it’s impossible that they come back,” he said. “It’s not ready to be inhabited.”

Mustafa Salim contributed to this report.