Similar scenes played out in Mosul, Iraq’s second-largest city.

Backed by American-led coalition airstrikes, Iraq government forces celebrated their recapture of the city in July. But Mosul’s recovery is a tale of two cities.

In the eastern portion, somewhere between 80 and 90 percent of the population that fled during initial fighting over the city have already returned to their homes. But nine months of fighting in the west of Mosul, where militants holed up during their final stand, left the area virtually uninhabitable.

From medical centers to centuries-old mosques, major structures were reduced to rubble and whole neighborhoods wiped off the map. Some fell at the hands of militants who demolished infrastructure as the Iraqi military moved in, including the iconic Al Nuri mosque and its leaning minaret, and some were casualties of coalition airstrikes. Before the Islamic State captured the city, Mosul was home to 1.1 million people. United Nations officials estimate that just restoring basic services there could cost more than $1 billion.

Leila Jane Nassif, the United Nations refugee agency’s assistant representative in Iraq, said the damage in the western part of the city had left hundreds of thousands of people displaced. It is unclear when they will be able to return.

“It will take time for the infrastructure to be in place and for people to be able to rebuild their lives there with so much housing that has been damaged,” Ms. Nassif said in a telephone interview.