MOSUL, Iraq — Prime Minister Haider al-Abadi congratulated Iraqi troops Sunday in the streets of Mosul for driving Islamic State militants out of most of the city. But airstrikes and sniper fire continued amid the revelry, and the extremists stubbornly held small patches of ground west of the Tigris River.
Over the nearly nine-month campaign, Iraqi forces — backed by airstrikes from the U.S.-led coalition — reduced the IS hold on Iraq's second-largest city to less than a square kilometer (less than a mile) of territory.
Still, al-Abadi and Iraqi commanders stopped short Sunday of declaring an outright victory against the extremists, who have occupied Mosul for three years. Losing Mosul would be a major defeat for the Islamic State, which has suffered major setbacks in the past year.
"We are glad to see normal life return for the citizens," al-Abadi said, according to a statement from his office. "This is the result of the sacrifices of the (country's) heroic fighters."
Dressed in a black military uniform, the prime minister met field commanders, kissed babies and toured a reopened market in western Mosul. At one point, he briefly draped an Iraqi flag on his shoulders.
A few kilometers away, special forces commanders climbed over mounds of rubble on the edge of Mosul's Old City to plant an Iraqi flag on the western bank of the Tigris, marking weeks of hard-fought gains in the heart of the congested district.
Suddenly, two shots from an IS sniper rang out, sending the men scrambling for cover. The flag was retrieved and planted farther upriver behind a wall that protected it from a cluster of IS-held buildings nearby.
"We've been fighting this terrorist group for 3 1/2 years now," said Lt. Gen. Abdul Wahab al-Saadi of the special forces. "Now we are in Mosul, the east part was liberated, and there's only a small part left in the west."
Al-Saadi emphasized that despite the flag-raising, the operation to clear Mosul of the militants was ongoing. Behind him, a group of soldiers and local journalists recording the scene sang a traditional Iraqi victory ballad.
Lt. Gen. Jassim Nizal of the army's 9th Division said his forces achieved "victory" in their sector, after a similar announcement a day earlier by the militarized Federal Police.
Soldiers danced atop tanks to patriotic music even as airstrikes sent up plumes of smoke nearby.
But the backdrop to the moments of revelry was a grinding conflict and widespread devastation.
Inside the Old City — home to buildings that date back centuries — the path carved by Iraqi forces leveled homes, shattered priceless architecture and littered the narrow alleys with corpses decomposing in the summer heat.
Less than an hour after the flag-raising, special forces Lt. Col. Muhanad al-Timimi was told that two of his men were shot by an IS sniper, and one of them had died.
"He was one of our best," al-Timimi said. "He just got married six months ago."
Blocks from the army celebrations, a line of weary civilians walked out of the Old City, past the shells of destroyed apartment blocks lining roads cratered by airstrikes.
Heba Walid held her sister-in-law's baby, which was born into war. The parents of the 6-month-old, along with 15 other family members, were killed last month when an airstrike hit their home. When Walid ran out of formula, she fed the baby a paste of crushed biscuits mixed with water.
Inside IS-held territory, the extremists are using human shields, suicide bombers and snipers in a fight to the death that has slowed recent Iraqi gains to a crawl.
Islamic State militants seized Mosul in the summer of 2014 when they swept across northern and central Iraq. That summer, the group's leader, Abu Bakr al-Baghdadi, appeared at Mosul's al-Nuri Mosque and declared a caliphate on territory it seized in Iraq and Syria.
Iraq launched the operation to retake Mosul in October. The fierce battle has killed thousands and displaced more than 897,000 people.
Last month, as Iraqi troops closed in on the Old City, the militants destroyed the al-Nuri Mosque and its famous leaning minaret to deny the forces a symbolic triumph.
U.S.-backed Syrian forces have encircled and pushed into the Islamic State's de facto capital of Raqqa in neighboring Syria after a month of fighting, although a long battle lies ahead.
More than 2,000 militants are holed up with their families and tens of thousands of civilians in Raqqa's center, the city's most densely populated districts.
The extremists still hold several smaller towns and villages across Iraq and Syria.
Salaheddin reported from Baghdad. Associated Press writer Salar Salim in Mosul contributed.