Philippine President Rodrigo Duterte has declared the city of Marawi liberated though the military continues to battle Muslim militants. Picture: AP Photo/Aaron Favila

Marawi, Philippines — Philippine President Rodrigo Duterte has declared the southern city of Marawi liberated though the military continues to battle a dwindling band of Muslim militants.

Duterte spoke Tuesday in Marawi before an audience of troops at a ruined school campus more than a kilometre from the area where fighting continues.

"Ladies and gentlemen, I hereby declare Marawi city liberated from the terrorist influence," he said to cheers.

Military chief General Eduardo Ano told AP that Duterte's statement means the threat from the militants, who've been fighting in Marawi since May 23, is substantially over. "They're leaderless and they have no more organization," he said. "There are still skirmishes."

Sporadic gunfire and explosions were 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, hoped it is the final phase of defeating a dwindling band of fighters who have occupied Marawi for five months.

Military spokesperson Restituto Padilla said Tuesday there were 20 to 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.

Associated Press