Iraqi Prime Minister Haider al-Abadi formally declared victory over Daesh on Monday in a speech on state television, marking the biggest defeat for the group since it declared a so-called 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.
TRT World spoke to journalist Ash Gallagher in Erbil.
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 Daesh leader Abu Bakr al-Baghdadi, who announced the founding of the caliphate from Mosul three years ago, is not clear.
The coalition said in a statement Iraqi forces were in "firm control" of Mosul, but some areas still needed to be cleared of explosive devices and possible Daesh fighters in hiding.
Around the time of Abadi's announcement, Daesh released a statement claiming to have mounted an attack on Iraqi forces in Mosul.
However, this report could not immediately be verified.
The United States hailed the retaking of Mosul, calling it a "critical milestone" in the fight against Daesh.
"On behalf of President Trump and the American people, I congratulate Prime Minister Abadi and the Iraqi people on their liberation of Mosul," US Secretary of State Rex Tillerson said.
The defeat of the group in Mosul had been expected for some time, and there were several reports last week of Iraqi troops celebrating Daesh's defeat.
TRT World's Chelsea Carter looks back over the three years that Daesh was in Mosul.
However, the militants vowed to "fight to the death" and by Sunday they were cornered in the two neighbourhoods of Qiliat and Shahwan.
Cornered in a shrinking area, the militants resorted to sending women suicide bombers among the thousands of civilians who are emerging from the battlefield wounded, malnourished and fearful.
The battle has also exacted a heavy toll on Iraq's security forces.
The Iraqi government does not reveal casualty figures, but a funding request from the US Department of Defense said the elite Counter Terrorism Service, which has spearheaded the fight in Mosul, had suffered 40 percent losses.
The US leads an international coalition that is backing the campaign against Daesh in Mosul by conducting airstrikes against the militants and assisting troops on the ground.
The Department of Defense has requested $1.269 billion in US budget funds for 2018 to continue supporting Iraqi forces.
Without Mosul - by far the largest city to fall under the group's control - Daesh's dominion in Iraq will be reduced to mainly rural, desert areas west and south of the city where tens of thousands of people live.
It is almost exactly three years since the terrorist group's leader al-Baghdadi proclaimed a "caliphate" spanning Syria and Iraq from the pulpit of the medieval Grand al-Nuri mosque.
Abadi declared the end of Daesh's "state of falsehood" a week ago, after security forces retook the mosque - although only after retreating militants blew it up.
The UN predicts it will cost more than $1 billion to repair basic infrastructure in Mosul.
In some of the worst affected areas, almost no buildings appear to have escaped damage and Mosul's dense construction means the extent of the devastation might be underestimated, UN officials said.
Daesh fighters are expected to revert to insurgent tactics as they lose territory.
The fall of Mosul also exposes ethnic and sectarian fractures between Arabs and Kurds over disputed territories or between Sunnis and the Shia majority that have plagued Iraq for more than a decade.