MANILA - The deaths of top militant leaders Isnilon Hapilon and Omar Maute are a major victory for the Philippine military which has been criticised for its slow progress in driving out rebels who overran the southern city in May.
Here's a timeline of the key events in the Marawi siege:
Hundreds of Muslim militants overrun Marawi, a city of about 200,000, considered as centre of the Islamic faith in the southern island of Mindanao. The surprise attack comes after security forces attempt to arrest Isnilon Hapilon, designated South-east Asia "emir" of the ultra-radical Islamic State in Iraq and Syria (ISIS).
The gunmen seize a hospital, free inmates at a jail, torch a number of buildings, take hostages including Catholic priest Teresito Soganub, and dig in.
President Rodrigo Duterte, in Moscow for a scheduled meeting with his Russian counterpart Vladimir Putin, places Mindanao, home to 20 million, under martial rule. Marawi residents begin to evacuate. Within the week, security officials disclose that among the militants are fighters from Indonesia, Malaysia, Singapore, Yemen and Saudi Arabia.
By this time, over 80,000 has fled Marawi.
Ten soldiers are killed in friendly fire, in the first big setback for the military in its bid to retake Marawi.
A deadline set by Defence Secretary Delfin Lorenzana to end the conflict lapses.
Security forces arrest Cayamora Maute, the ailing father of militant brothers Abdullah and Omar Maute, who with Hapilon plotted and led the Marawi siege.
The Maute brothers' mother, Ominta Romato Maute, also known as "Farhana", is arrested. She is said to have financed her sons' efforts to form an armed group to protect the family's turf.
Thirteen Marines are killed as they try to clear homes and buildings amid sniper fire and booby traps.
The military again misses a self-imposed deadline to liberate Marawi on Philippine independence day.
The government announces it is aware of the ISIS plot to seize Marawi, but admits to underestimating the enemy's strength and resolve.
Security officials announce they have seized 11kg of methamphetamine with a street value of 250 million pesos (S$6.6 million). They claim the militants are being fuelled by methamphetamine, and that the conflict in Marawi has its roots in a turf war over drugs.
Duterte visits Marawi for the first time.
Congress agrees to extend martial law in Mindanao till the end of the year. Another deadline lapses.
After a two-month standoff, security forces finally gain a major victory. They seize two bridges leading to positions held by the militants in Marawi's now bombed-out business district.
Duterte visits Marawi for a second time.
The Marawi campus of Mindanao State University re-opens, amid heavy guard.
Duterte visits Marawi for a third time, just after the army retakes a grand mosque and a police station.
Security forces retake a Catholic cathedral seen in an ISIS video early in the fighting being vandalised by the militants.
Cayamora Maute, a diabetic, dies in detention, as he experiences hypertension.
Security officials say the military is on its "final push", and that fighting is expected to intensify.
Duterte visits Marawi for the fourth time.
Catholic priest Soganub is rescued.
Duterte visits Marawi for a fifth time. He shows a matrix claiming drug money fuelled the Marawi war.
Security forces retake the last of three strategic bridges in Marawi.
The military misses yet another deadline.
More hostages escape, but reports say the militants are holding some 60 more.
The military sets an Oct 15 deadline.
By this time, a total of 161 soldiers and 47 civilians have already died in the battle. The military claims killing at least 817 militants. Over 359,600, meanwhile, have been displaced.
The deadline set for ending the war.
Government forces kill Hapilon and Omarkhayam Maute.