The insurgent leader Isnilon Hapilon was killed in October, near the end of the siege. But about 200 fighters had managed to escape, and sporadic clashes continued weeks later.

Long known as the “Islamic capital” of the Philippines, Marawi has a history of marginalization by the government of the predominantly Catholic country. Even before the siege began, residents would stay away from banks in favor of keeping their money in vaults and doing business among themselves. Many refused to register their property, preferring to stay off government books.

As people began returning this week, some said they believed that the Philippine military, not the Islamist militants, had looted their homes. That has only added to the sense of isolation.

“Our practice was staying together and closely guarding each other,” said Samira Gutoc, a community organizer from Marawi. “Now, if you’re a Muslim Filipino, you’re going to be suspected of being a part of this.”

Across the city, the residents tried to gather up whatever belongings they could: scrap metal to sell in the market, old family photo albums, half-burned high school diplomas.

In the center of the city, Dr. Bedoria Macabalang, 52, was inspecting what remained of the family-owned, 50-bed Salaam Hospital, which was one of the city’s most modern health facilities before the siege began. Militants had taken over the hospital and used it as an infirmary for their wounded. On the walls were pro-Islamic State graffiti.