Philippine President Rodrigo Duterte has declared the city of Marawi “liberated” from militants, even as fighting continues.
The army said it was battling up to 30 militants left in the city, who were holding about 20 hostages.
Marawi has been partly held by fighters linked to so-called Islamic State (IS) since an attack in May.
Troops have been trying to root them out in a conflict that has killed more than 1,000 people – mostly militants.
Mr Duterte made his announcement while addressing troops in Marawi on Tuesday, saying: “Ladies and gentlemen, I hereby declare Marawi liberated from the terrorists.”
Gunfire could be heard in the city just moments before he made that statement, according to reports.
A military spokesman described the president’s declaration as symbolic, but also as a signal to begin planning the reconstruction of Marawi, which has been largely destroyed by almost daily bombardment.
Separately, the military has said they were still conducting operations to flush out the remaining militants and rescue their hostages.
Mr Duterte’s declaration came a day after the army said they had killed top militants Isnilon Hapilon and Omar Maute.
The two men led the Abu Sayyaf and Maute groups which formed part of the insurgency in Marawi. Both groups have pledged allegiance to, or have links to, IS.
More than 800 militants have been killed in the fighting, which has also killed more than 150 government troops.
Nearly 50 civilians have been killed, and thousands more have fled the fighting.
Observers say the occupation of Marawi stoked fears that militant Islamist ideology is more prevalent on the island of Mindanao than had previously been imagined.
The region is the only Muslim-majority part of the otherwise largely Catholic Philippines.