Iraq’s Prime Minister Haider al-Abadi has formally declared victory over the Islamic State of the Iraq and Levant (ISIL) in Mosul.

“I announce from here the end and the failure and the collapse of the terrorist state of falsehood and terrorism which the terrorist Daesh announced from Mosul,” Abadi said on Monday evening, using an Arabic acronym for Islamic State.

Abadi, wearing a black military uniform and flanked by commanders from the security forces, thanked troops and the US-led coalition that backed the offensive. But he warned that more challenges lay ahead.

“We have another mission ahead of us, to create stability, to build and clear Daesh cells and that requires an intelligence and security effort, and the unity which enabled us to fight Daesh,” he said before raising an Iraqi flag.

Mosul residents speak of horror as ISIL fights to death

A 100,000-strong coalition of Iraqi government units, Kurdish Peshmerga fighters and Shia armed groups launched the offensive to recapture the city from the militants in October, with key air and ground support from an international coalition.

The commander of the US-led coalition said Iraqi troops have firm control of the city, but some areas still must be cleared of explosive devices and possible ISIL fighters.

“This victory alone does not eliminate (ISIL) and there is still a tough fight ahead. But the loss of one of its twin capitals and a jewel of their so-called caliphate is a decisive blow,” Lieutenant General Stephen Townsend said in a statement.

‘Lost everything’

Earlier in the day, Iraqi commanders said they believed hundreds of ISIL fighters remained inside the group’s last enclave and were using their families – including women and children – as human shields in a fight to the death.

It was not clear if the clashes had ended.

Abadi has congratulated Iraqi troops on their “victory” on previous occasions despite ongoing clashes.

Brigadier General Haider Fadhil of the Iraqi special forces told The Associated Press news agency that even after ISIL is defeated, Iraqi forces will need to carry out clearing operations to root out sleeper cells and defuse booby traps.

A spokesman for UN Secretary-General Antonio Guterres said on Monday the recovery of Mosul was “a significant step in the fight against terrorism and violent extremism”.

OPINION: What’s next after Mosul?

The cost of the nearly nine-month battle has been enormous: much of Mosul in ruins, thousands dead and wounded and nearly a million people forced from their homes.

Civilians who have fled fighting in Mosul face a dire humanitarian crisis with the Norwegian Refugee Council (NRC) saying displaced civilians are living in “incredible hardship” in temporary camps.

“Temperatures in this part of Iraq are topping 45 degrees. People are living in camps. They need a lot of water, and the threat of disease looms in this kind of weather,” the NRC’s Melany Markham told Al Jazeera from Erbil.

The UN says 920,000 civilians have fled their homes since the military campaign began in October. Close to 700,000 people are still displaced.

Is it the beginning of the end for ISIL? – Inside Story

The UN refugee agency said on Monday it could be many months before civilians are able to return to their homes because of “extensive damage caused during the conflict”.

“It’s a relief to know that the military campaign in Mosul is ending. The fighting may be over, but the humanitarian crisis is not,” Lise Grande, the UN’s humanitarian coordinator in Iraq, said in a statement.

“Many of the people who have fled have lost everything. They need shelter, food, health care, water, sanitation and emergency kits. The levels of trauma we are seeing are some of the highest anywhere. What people have experienced is nearly unimaginable.”

While defeat in Iraq’s second-largest city deals a heavy blow to ISIL, the group controls several cities and towns south and west of Mosul.

ISIL is also under heavy pressure in its operational headquarters in the Syrian city of Raqqa and its self-proclaimed caliphate that once straddled the two countries is crumbling.

Source: Al Jazeera and news agencies