Iraqi federal forces, Sunni tribes and Shiite militias retook most of Dhuluiyah town from the Islamic State group Friday, in one of the most significant victories over the jihadists.
A Sunni tribe in the south of the town, 90 kilometres (55 miles) north of the capital, had been holding out against relentless attacks for nearly four months.
Iraq's military announced that all jihadists had left the town.
But some fighters on the ground were more cautious, saying there was one area pro-government forces had yet to enter.
"Dhuluiyah has been completely cleared of IS," Lieutenant General Mohammed al-Askari, the defence ministry spokesman, told AFP.
"The Iraqi army, as well as volunteers from the tribes and popular brigades (Shiite militias), entered Dhuluiyah and have now reached the office of the mayor," he said.
The Jubur tribe in the south of the town has been holding out since June against relentless attacks by the jihadists.
A victory against IS there has been described as crucial to efforts by the government to show it was willing to support Sunni tribes rejecting IS.
"The army arrived from the north," said Abu Haitham al-Juburi, a fighter from the southern Jubur neighbourhood.
He said the operation was coordinated with other Sunni tribes and explained that pro-government forces had left an escape route open for the jihadists in order to avoid more bloodshed.
"The officer in charge decided not to attack... tonight in order to minimise casualties. We will go there tomorrow," he said.
"The fighting was really intense today especially from 8:00 am to 3:00 pm (1200 GMT)," said Mustafa Nadhom, another fighter, speaking by phone from the frontline.
Signup to our newsletter and follow us on Facebook and Twitter!
"Today we killed 25 members of IS. Most of them were Arab foreign fighters, including two with British citizenship and two Yemenis," he said.
"Now there are small clashes but it's mostly quiet. We will make the final push tomorrow."
- Celebrations -
A police officer in Dhuluiyah said around 80 percent of the town was now fully under pro-government control.
Residents and fighters said several hundred jihadists had fled the town but said the neighbourhood formerly occupied by the IS group may have been booby-trapped.
The jihadists had launched a huge attack earlier this week in a bid to break months of resistance by the Jubur tribe.
But several Sunni tribes from the area, as well as contingents of Shiite militiamen who have been fighting alongside the army, repelled the attack.
The Jubur neighbourhood had remained largely cut off from the rest of Iraq for weeks, with fighters only able to go in and out using boats on the Tigris.
"This is a big victory for us," said fighter Mustafa Nadhom.
"There were some celebrations this evening but they were not very big because Jubur has lost around 120 people since the start of the fighting. And around 600 people have been wounded."
"In these long months of battle, they have tried everything against us -- mortar attacks, chlorine, car bombs -- but we are still here."
Jubur, which played a prominent role in the formation of US-backed Sunni tribal forces to combat IS's previous incarnation in 2005-2007, had for weeks been pleading for more assistance.
The army and allied Shiite militias, as well as Kurdish peshmerga troops, also gained ground north of Dhuluiyah in Salaheddin and Kirkuk provinces this week.