MOSUL, Iraq — Iraq’s prime minister has returned to Mosul and declared “total victory” in the fight against the Islamic State group there, though some fighting is expected to continue.

Prime Minister Haider al-Abadi had congratulated Iraqi troops on their “victory” on previous occasions despite ongoing clashes. The latest announcement came in a statement posted on Twitter.

Hours earlier, Associated Press reporters had seen heavy fighting still underway. It was not immediately clear if the clashes had ended.

U.S.-backed Iraqi forces launched a massive operation to retake Mosul in October, and in recent days they had confined the remaining few hundred militants in an area measuring less than a square kilometer (less than a mile).

Iraqi forces were still battling Islamic State militants in a small area of Mosul on Monday, a day after the prime minister visited to congratulate the troops on retaking nearly all of Iraq’s second largest city.

Brig. Gen. Haider Fadhil of the Iraqi special forces said even after the militants are defeated in the last pocket under their control, Iraqi forces will need to carry out clearing operations to root out sleeper cells and defuse booby traps.

Iraqi commanders believe hundreds of IS fighters remain inside the group’s last enclave and are using their families — including women and children — as human shields in a fight to the death. Humvees could be seen racing out of the Old City on Monday, ferrying wounded soldiers to field hospitals.

“There’s no accurate estimate for the Daesh fighters and the families who are stuck there,” said Lt. Gen. Abdul-Ghani al-Asadi, a senior special forces commander, using the Arabic acronym for IS.

He said most civilians left in the Old City are believed to be IS family members. “But we will not accuse them of anything,” he said. “if they don’t carry weapons they are civilians.”

The battle for Mosul has killed thousands and displaced more than 897,000 people, and the United Nations said Monday there was no end in sight to the humanitarian crisis in Iraq despite the recent gains in Mosul.

It said thousands of Mosul residents will likely remain displaced from the city after the fight is concluded because of “extensive damage caused during the conflict.”

Airstrikes, artillery and militant bombings have destroyed thousands of buildings as well as key infrastructure in Mosul. Iraq’s Interior Ministry says more than half of all buildings in western Mosul, where the fighting was heaviest, were damaged or destroyed.

Mosul, Iraq’s second-largest city, fell to the Islamic State group in 2014, when IS blitzed across much of northwestern Iraq and subsequently declared a caliphate in the territory under its control in Iraq and Syria.

Iraqi forces launched the operation to retake Mosul last October and by late January, the eastern half of the city was declared liberated. The push into western Mosul began the following month. In June, Iraqi forces started the weeks long push through the Old City, Mosul’s most congested district.

On Sunday, as Iraqi soldiers celebrated recent gains, al-Abadi had stopped short of declaring an outright victory.

On his visit to Mosul, al-Abadi met field commanders, kissed babies and toured a reopened market. But air strikes and sniper fire continued amid the revelry.

Over the nearly nine-month campaign, Iraqi forces have reduced the IS hold on Mosul to less than a square kilometer (less than a mile) of territory.

“We are glad to see normal life return for the citizens,” al-Abadi said, according to a statement from his office. “This is the result of the sacrifices of the (country’s) heroic fighters.”

A few kilometers away, special forces commanders climbed over mounds of rubble on the edge of the Old City to plant an Iraqi flag on the western bank of the Tigris, marking weeks of hard-fought gains.