Iraqi Prime Minister Haider al-Abadi formally declared victory over Islamic State in the city of Mosul on Monday, marking the biggest defeat for the group since it declared a caliphate three years ago.
"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," he said in a speech shown on state television, using an Arabic acronym for Islamic State.
The fall of Mosul effectively marks the end of the Iraqi half of the Islamic State caliphate, which also includes territory in Syria. The group still controls territory west and south of the city.
A 100,000-strong coalition of Iraqi government units, Kurdish Peshmerga fighters and Shi'ite militias launched the offensive to recapture the city from the militants in October, with key air and ground support from a US-led coalition.
Abadi, wearing a black military uniform and flanked by commanders from the security forces, thanked troops and the coalition. 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.
About 900,000 residents have been displaced by the fighting, and thousands of civilians are believed to have been killed.
The whereabouts of Islamic State leader Abu Bakr al-Baghdadi, who announced the founding of the caliphate from Mosul three years ago, is not clear.
There have been several unconfirmed claims of his death. US and Iraqi military sources say he may be hiding in the border area between Iraq and Syria.