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.
- Who are the Abu Sayyaf group?
- Maute rebel group: Rising threat to Philippines
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.
- Starving residents tell of terror in Marawi
- Duterte: The controversial ‘strongman’ of the Philippines
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.
Who was Isnilon Hapilon?
- A leader of Abu Sayyaf, a group notorious for kidnapping, piracy and for beheading hostages, including foreigners
- Factions of the group aim to create an Islamic caliphate in the southern Philippines, while others have pursued criminal activity
- Isnilon Hapilon pledged allegiance to IS in 2014 – IS later urged all Muslims in southeast Asia to unite under his leadership
- The US has offered a bounty of up to $5m for him
- Has links to the Maute group, another local insurgency group which has declared allegiance to IS
The tenacious resistance of the militants, an alliance of two groups pledging allegiance to so-called Islamic State, caught the government by surprise, the BBC’s Jonathan Head reports.
Armed groups have fought intermittently for more autonomy on the island of Mindanao for decades, but rarely as fiercely as those who held Marawi over the past five months.
The growing radicalisation of parts of Muslim society in the Philippines has been attributed by some observers to the slow pace of the long-running peace talks with the government.