AL-HUD, Iraq — The mutilated bodies of Islamic State group fighters were still strewn on the ground of this northern Iraqi town on Wednesday. One was burned. Another’s face was flattened by abuse.

Iraqi troops on the march toward Mosul moved into al-Hud a day earlier and declared it liberated. But they found residents had already risen up and killed many of the militants in the town themselves.

With the offensive to recapture Mosul in its third day, Iraqi forces advancing from the south and east are fighting to retake the towns and villages the dot the plains and line the Tigris River leading to the city. At times, they’ve met fierce resistance, with the militants sending explosives-packed vehicles careening toward the troops’ positions.

This area has been under control of the militants ever since the summer of 2014, when IS fighters captured Mosul and much of the north in a lightning advance.

In al-Hud, a Sunni Arab town on the Tigris, residents saw their chance to get rid of them. On Monday, a man paraded through town with an Iraqi flag in a show of defiance, residents told The Associated Press. IS fighters shot and killed him.

A group of residents gathered in a shop, news spread among the hundreds of people living in the town, and soon a crowd turned on the militants.

One resident, Ahmed Mohammed, said he and others shot a militant who was hiding by an outhouse behind a shop. “That didn’t work. Then one of our guys came and threw a grenade on him from the top,” he said.

Gasim Mohammed said his father was killed in the uprising against the militants. He kicked the head of one of the bodies. “This one smells like a dog,” he said.

“I hate them. Anyone I catch, I’ll drink his blood. Even if it’s a child,” he said.

It was not clear how many militants had been in the village or how many were killed. The Associated Press saw at least five bodies.

The head of the Iraqi military’s operations command for Nineveh province where the offensive its taking place confirmed the residents’ account.

“Before we reached the village they fought them and killed many of them,” Maj. Gen. Najim al-Jobori said.

On Wednesday, residents were celebrating. Children ran toward an Iraqi military convoy waving peace signs while others threw stones at the bodies of the dead IS fighters. Residents fired celebratory rounds into the air and cars long the main road still flew white flags of surrender.

At Qayara air base, near al-Hud, a senior Iraqi general called on Islamic State group fighters in Mosul to surrender. Lt. Gen. Talib Shaghati told reporters that up to 6,000 IS fighters are in the city.

East of Mosul, troops have moved about a kilometer (half-mile) from Hamdaniyah, a historically Christian town also known as Bakhdida, to the east of Mosul, an Iraqi officer from the 9th Division told the AP.

Over the past day, IS sent 12 car bombs against the troops, all of which were blown up before reaching their targets, he said, adding that Iraqi troops suffered a small number of casualties from the mortar rounds. The officer, who spoke on condition of anonymity because he was not authorized to talk to reporters, did not provide specific figures.

At least 5,000 people fled the Mosul area to a refugee camp in northeastern Syria in the last 10 days, with another thousand waiting to enter at the border, Save the Children said.

Tarik Kadir, head of the group’s Mosul response, said conditions there are “among the worst we’ve seen.” More than 9,000 people in the camp only have access to dirty, untreated water and have to share 16 latrines, leaving the area polluted by human waste “with a looming risk of disease,” the group said.

U.N. humanitarian chief Stephen O’Brien told the U.N. Security Council that no large-scale displacement of civilians has been reported since the operation began.

But he said the U.N. anticipates “a displacement wave of some 200,000 people over the coming weeks, with up to one million displaced in the course of the operation in a worst-case scenario.”

Associated Press writers Qassim Abdul-Zahra in Khazer, Iraq, and Sinan Salaheddin and Joseph Krauss in Baghdad contributed to this report.