MOSUL, Iraq — The fighting is all but over in Mosul, and the billboards are already up: hastily raised signs in which the government urged the city’s Sunni residents to “turn the page” from the terrorists of the Islamic State.

As Prime Minister Haider al-Abadi visited Mosul to declare victory and call for unity, civilians on the longer-secured east side of the city danced and waved Iraqi flags. Some called for brotherhood between Sunnis and Shiites, or chanted, “By our souls and blood, we sacrifice for you, Iraq!”

It is a moment for Iraqis to celebrate after nearly nine months of bloody warfare against the Sunni extremists of the Islamic State. But despite the flaring of hope for a new national unity, the government’s costly victory in Mosul and the questions hanging over its aftermath feel more like the next chapter in the long story of Iraq’s unraveling.

Most pressing is the need to bring back hundreds of thousands of displaced Sunni civilians. But Iraq has failed to rebuild and resettle some other communities freed from the Islamic State as tensions between the Sunni minority and the majority Shiites still undermine efforts to reunite the country.