Iraqi Prime Minister Haider al-Abadi arrived in Mosul on Sunday and congratulated the armed forces for their "victory" over Daesh after nearly nine months of urban warfare, bringing an end to jihadist rule in the city.
Daesh's defeat in Mosul three years after taking the city is a major blow for the hardline Sunni Islamist group, which is also losing ground in its operational base in the Syrian city of Raqqa from where it has planned global attacks.
The group, however, still controls territory in Iraq and is expected to revert to more conventional insurgent tactics such as bombings as its self-proclaimed caliphate falls apart.
The battle for Mosul – by far the largest city to fall under the militants' control – has left large areas in ruins, killed thousands of civilians and displaced nearly 1 million people.
"The commander in chief of the armed forces (Prime Minister) Haider al-Abadi arrived in the liberated city of Mosul and congratulated the heroic fighters and Iraqi people for the great victory," his office said in a statement.
State television later showed Abadi touring Mosul on foot alongside residents of Iraq's second-largest city.
Air strikes and exchanges of gunfire could still be heard in the narrow streets of Mosul's Old City, where the group has staged its last stand against Iraqi forces backed by a US-led international coalition.
Abadi met commanders in west Mosul who led the battle, but he has yet to issue a formal declaration that the entire city has been retaken from the group which is also known as ISIS.
Abadi's spokesman, Saad al-Hadithi, said victory would not be formally declared until the few remaining Daesh militants were cleared from Mosul.
Still, France and Britain, members of the coalition that has conducted air strikes and provided training and assistance to Iraqi forces on the battlefield, welcomed the defeat.
"Mosul liberated from ISIS: France pays homage to all those, who alongside our troops, contributed to this victory," French President Emmanuel Macron tweeted.
"I congratulate Prime Minister Abadi, and the Iraqi forces who have been fighting on the ground with great bravery and care against a brutal opponent," British Defence Secretary Michael Fallon said in a statement.
While celebrating "the removal of the death cult from Mosul", Fallon said the military operation was not over.
This barbaric group remains dug in west of the Euphrates and clearing operations in and around Mosul will be needed because of the threat from improvised explosive devices.
In Washington, National Security Council spokesman Michael Anton, when asked whether the battle for Mosul was complete, replied: "Situation not resolved, but we are monitoring."
Defence Secretary Sir Michael Fallon welcomes Iraqi victory in Mosul: pic.twitter.com/hlzA7swz0V
— Ministry of Defence (@DefenceHQ) July 9, 2017
Iraq still faces uncertainty and long-term stability will be possible only if the government contains ethnic and sectarian tensions which have dogged the country since the overthrow of Saddam Hussein in 2003.
The fall of Mosul exposes fractures between Arabs and Kurds over disputed territories, and between Sunnis and the Shi'ite majority.
The group vowed to "fight to the death" in Mosul, but Iraqi military spokesman Brigadier General Yahya Rasool told state TV that 30 militants had been killed attempting to flee by swimming across the River Tigris that bisects the city.
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, Iraqi army officers said.
The struggle 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 (CTS), which has spearheaded the fight in Mosul, had suffered 40 percent losses.
The Department of Defense has requested $1.269 billion in US budget funds for 2018 to continue supporting Iraqi forces, which collapsed in the face of the few hundred militants who overran Mosul in 2014.
Backed by coalition air strikes, an array of Iraqi forces gradually clawed back territory from Daesh until reaching Mosul, the group's de facto capital in Iraq, last October.
It is almost exactly three years since the ultra-hardline group's leader, Abu Bakr al-Baghdadi, proclaimed a "caliphate" spanning Syria and Iraq from the pulpit of Mosul's 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 United Nations 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, U.N. officials said.