By Roli Ng and Manuel Mogato
MARAWI CITY/CLARK, Philippines (Reuters) - The Philippines announced on Monday the end to five months of military operations in a southern city held by pro-Islamic State rebels, after a fierce and unfamiliar urban war that has marked the country's biggest security crisis in years.
Offensive combat operations were terminated after troops prevailed in what was the last stand against rebel gunmen who clung on inside several buildings in the heart of Marawi, and refused to surrender.
The bodies of 40 of those fighters and two of their wives were found on Monday in two buildings and a mosque in the battle zone. Artillery and automatic gunfire were still heard on Monday and Reuters journalists saw flames behind a mosque.
Defence Secretary Delfin Lorenzana said in killing off the extremists, the Philippines had "nipped the budding infrastructure and defeated terrorism".
"In crushing thus far the most serious attempt to export violent extremism and radicalism in the Philippines and in the region, we have contributed to preventing its spread in Asia," Lorenzana said in Clark at a meeting of regional defense ministers.
The rebel occupation stunned a military inexperienced in urban combat and stoked wider concerns that Islamic State loyalists have gained influence among local Muslims and have ambitions to use the island of Mindanao as a base for operations in Southeast Asia.
Those fears are compounded by the organization of the militant alliance and its ability to recruit young fighters, stockpile huge amounts of arms and endure 154 days of ground offensive and air strikes that have devastated the city.
The 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.
The center of the picturesque lakeside town is now in ruins due to heavy shelling and aerial bombing.
Military spokesman, Major General Restituto Padilla, confirmed there was still gunfire, but there were "no more terrorists".
Colonel Romeo Brawner, deputy task force commander in Marawi, said offensives had stopped but troops would secure the city from militant "stragglers" who might still be alive.
"If we find them and they will attack our soldiers or even the civilians, then we will have to defend ourselves," he told reporters.
After months of slow progress, the military has made significant gains in retaking Marawi in the week since Isnilon Hapilon, Islamic State's "emir" in Southeast Asia and Omarkhayam Maute, a leader of the Maute militant group, were killed in a nighttime operation.
Another leader and possible bankroller of the operation, Malaysian Mahmud Ahmad, was likely killed also, the military said.
President Rodrigo Duterte had declared Marawi City liberated six days ago, even though battles were still ongoing. Padilla said that since that declaration the army had been fighting an enemy decimated by the loss of its leadership.
"They were formless, they had no place to run," he said.
Lorenzana said six battalions of troops would remain in Marawi and though the battle had been won, Islamic State's radical ideology had not been completely annihilated.
He thanked the United States, Australia, Singapore and China for providing technical support and weaponry, and said the conflict would be a catalyst for closer international cooperation against extremism.
(Additional reporting Romeo Ranoco in MARAWI and Neil Jerome Morales and Manolo Serapio Jr in MANILA; Writing by Martin Petty; Editing by Michael Perry)