Damaged buildings beside a mosque are seen after government troops cleared the area from pro-Islamic State militant groups inside a war-torn area in Marawi, Monday. Romeo Ranoco, Reuters

MANILA (UPDATED) - Combat operations in Marawi are finally over, Defense Secretary Delfin Lorenzana announced Monday, 5 months after the southern city was seized by Islamic State-linked militants.

Lorenzana said there are no more terrorists in the war-torn city as the last group of the Maute fighters were killed in a final firefight Sunday. He said 42 cadavers were recovered after the encounter.

"There are no more militants in Marawi," Lorenzana announced during a meeting of regional defense ministers in Clark, Pampanga.

Military spokesperson Major General Restituto Padilla said the Maute fighters were given a chance to surrender but they chose to fight up to the very end.

"We never ceased, we never stopped until the last fight yesterday. Then we seized the remaining buildings that they were holding [on] to. This is where we confiscated their .50 caliber machine gun, one of their formidable defense. With that it signaled the last remnants escaping which our troops pursued," he said.

#ANCRecap: AFP Spokesperson Maj. Gen. Restituto Padilla gives details on the end of combat operations in Marawi. pic.twitter.com/BE47YXAA2s — ABS-CBN News Channel (@ANCALERTS) October 23, 2017

According to Armed Forces chief of staff Eduardo Año, the terrorists confined themselves in 2 buildings, including a mosque, where the last fighting occurred, and where 20 more hostages were rescued.

He said among those killed in the final encounter were wives of 2 terrorists who fought the troops as well.

Authorities said 920 militants, 165 troops and police and at least 45 civilians were killed in the conflict, which displaced more than 300,000 people.

Troops also recovered the bodies of a policeman and a soldier yesterday. Año said the body of the cop was burned while the soldier was beheaded.

"Ngayon ang hahanapin po natin ay the stragglers. Maaaring may naiwan na stragglers. Hahanapin din natin 'yung cadavers. We will clear the area of explosives," he added.

President Rodrigo Duterte last week announced that the city has been "liberated from terrorist influence" following the killing of extremist leaders Isnilon Hapilon and Omar Maute.

The AFP had withheld similar declarations as it zeroed in on several insurgents, including 3 sons of Hapilon and several foreigners.

The 154-day Marawi occupation, the Philippines' biggest security crisis in years, has triggered concerns that with its mountains, jungles and porous borders, the island of Mindanao could become a magnet for Islamic State fighters driven out of Iraq and Syria.

More than 1,000 people, mostly rebels, were killed in the battle and the heart of the city of 200,000 has been leveled by air strikes.

Government has begun laying down plans to rebuild Marawi, once a bustling urban and cultural capital and the country's only Islamic city.

The military has also commenced a gradual pullout of troops from the battle zone. With Reuters and Willard Cheng, ABS-CBN News