Sporadic gunfire and explosions can be heard in the southern Philippine city of Marawi as soldiers fight the remaining Islamic militants to gain control of the last pocket of the city.

The military, which killed two key militant leaders on Monday, hopes it is the final phase of defeating a dwindling band of fighters who have occupied Marawi for five months.

Military spokesman Restituto Padilla said Tuesday there were 20-30 militants left, including about six to eight foreign fighters.

The lakeside city has been devastated by fighting that began May 23.

Philippine flags hung from pockmarked buildings and houses, their roofs either blasted away or riddled with gunshot holes.

Soldiers stood guard in front of some buildings and at intersections where battle debris has been shoveled to the side.