Iraqi Prime Minister Haider Abadi flew to war-ravaged Mosul on Sunday to congratulate the country's armed forces as they were on the cusp of defeating Islamic State militants in what was once the crown jewel of their self-declared caliphate.
Dressed in a black Iraqi special forces uniform and flanked by military commanders, Abadi applauded "the heroic fighters and the Iraqi people for achieving the great victory," according to a statement from his office.
Abadi's kudos, however, fell short of a "mission accomplished" declaration marking the end of a nearly nine-month campaign to rout the extremists from Iraq's second-largest city. "One or two pockets of the remnants of Daesh remain," the government conceded in a later statement, using the Arabic acronym for Islamic State.
Only a few miles from where Abadi met with his troops, Islamic State militants and fighters from Iraq's Counter-Terrorism Service battled cheek by jowl in Mosul's Old City.
Warplanes from the U.S.-led coalition struck the militants, who were cornered in a pocket of a little more than 200 square yards, with the Tigris River behind them, officers said. Dozens were said to have been killed as they tried to make their escape by swimming across.
"The [Iraqi army's] 16th Division is on the other bank of the river, and they shot them," said 1st Lt. Mohammad Saheb, a commander with the Counter-Terrorism Service, which was leading the charge into Islamic State's last redoubt. "They're so close that their bullets almost hit us."
Iraqi officers expect vicious resistance from about 60 extremists who they believe will fight to the last man.
"They hide in tunnels, then run at you until they're within six or seven yards, before they detonate their suicide vest. You barely have time to shoot them first," said Haidar Jabbar, a soldier taking part in the fight.
"We've had many battles against Daesh, but ask anyone, they'll tell you this is the hardest one."
Saheb said the skirmishes were so close that his men couldn't rely on airstrikes at times. "We have to use low-powered grenades and flash-bangs to flush them out," he said.
As he spoke, a coalition airstrike hit a nearby house, giving the ground a powerful shake and showering Saheb with debris.
"We didn't even need loudspeakers when we were ordering them to come out and surrender," said Lt. Col. Ali Husseini, another Iraqi commander in Mosul. "They're in the next room, right across the wall."
Islamic State fighters have also intensified their use of improvised explosive devices, a signature tactic that the group used to powerful effect in other cities, such as Ramadi, but which it had thus far employed sparingly in Mosul.
"Every day we see new things. The other day they had booby-trapped an ammunition box, lacing it to two other explosives to kill anyone who opened it," said Lt. Col. Said Badr Kathem, a demolitions expert, in an interview near the front line.
Kathem said the group had also begun to deploy female suicide bombers, hiding them among fleeing civilians.
Islamic State's defeat in Mosul represents the harshest blow yet to the group — and a moment of redemption for Iraq's security forces.
When the militants first blitzed into the city three years ago, entire army divisions all but collapsed. Thousands of soldiers shed their uniforms and ran for their lives, abandoning millions of dollars' worth of U.S. military hardware.
Islamic State made no mention of the defeat on its official channels on the messaging service Telegram. Instead, in what is perhaps a harbinger of things to come in Mosul, it claimed responsibility for a suicide attack on an army headquarters in Hit, a town in Anbar province once held by the militants, but which government forces reclaimed more than a year ago.
In Mosul's eastern half — liberated in January and where life has largely returned to normal — Abadi glad-handed his way through crowds of civilians who cheered and raised their smartphone cameras to commemorate the moment.
The revelers honked horns and waved large Iraqi flags from the windows of cars snarled in the traffic behind his convoy. Fireworks could be heard above the crowd, as they shouted, "With our souls, with our blood, we sacrifice ourselves for Abadi."
But in west Mosul there seemed to be less appetite for cheer. The dislodging of Islamic State from this half of the city, with its older structures and narrower walkways, came at a high price. Entire neighborhoods were reduced to a post-apocalyptic landscape of ravaged masonry and crumpled vehicles. The sickly smell of decomposition is omnipresent.
The detritus of the militants' reign is visible inside these buildings. Large bombs — "they called them 'Hell of the Caliphate,'" said Jabbar, the soldier — lay beside a bag of bullets. A car rigged to explode, its shape made angular by added plating, sat in a garage. Floors were strewn with Islamic State prayer pamphlets.
Almost 1 million people have been displaced since the campaign began in October, according to government figures. Many have returned to the eastern side of the city, but tens of thousands of others are forced to endure Iraq's scorching summer in refugee camps dotting the desert landscape around Mosul.
The cost to rebuild the city, the United Nations says, will run into the billions, and a full reckoning of the dead will take months. Western aid officials privately fret that there is no coherent plan for how to govern the city after Islamic State's ouster.
Meanwhile, Islamic State, many say, is defeated but not vanquished.
It maintains control over bastions like Hawija, Tall Afar and parts of western Anbar. And it has shown an ability to play on the internal divisions plaguing the often-bickering forces arrayed against it.
Across the border, the group still holds sway in parts of eastern Syria, where fleeing fighters may be able to regroup. This, despite a U.S.-backed offensive by Kurdish and Arab militiamen to take back Raqqah, Islamic State's Syrian capital.
"It will not really be possible to definitively declare victory against Islamic State as it transforms to a traditional underground guerrilla-style insurgency," said Nussaibah Younis, an associate fellow at Chatham House, a London think tank.
"It's important that the international community doesn't take the liberation of Mosul as an excuse to withdraw their attention from Iraq … not just on the military side, but also on the political and humanitarian side."
Even in Mosul, the gains seem fragile. Residents speak of sleeper cells, and of former collaborators with the group who still walk among them.
They also face security forces who view them with suspicion — potentially stirring up sectarian divisions that made some welcome Islamic State's arrival three years ago.
"Now that the battle for Mosul has ended, the Iraqi state must provide safety and security for all civilians," said Heidi Diedrich, Iraq country director with the Norwegian Refugee Council aid group, in a statement. "Combatants must not take the law into their own hands."
Many soldiers said they expect to face the extremists in Mosul once more.
"I fought in this city from 2004 to 2009, from 2012 to 2013 and from 2016 till now," said Husseini, the commander, a thin smile on his face as he rested near the front line. "Maybe for now they're done, but they'll be back. Soon."
Bulos is a special correspondent.
7:30 p.m.: This article was updated with comment from analysts and other details.
1:10 p.m.: This article was updated throughout with Times reporting.