Prayer mats, checkered scarves, black fatigues, and bullet-ridden walls mark the hideout where the “emir” of the Islamic State in Southeast Asia spent months preparing the most brazen and devastating militant attack in the region.

The Philippines is preparing to declare the end of fighting in a southern city seized for five months by pro-Islamic State rebels, a top military commander said yesterday, as troops continued a phased withdrawal from the devastated lakeside city.