Philippine President Rodrigo Duterte declared the southern city of Marawi liberated from pro-Islamic State militants on Tuesday, although the military said 20-30 rebels were holding about 20 hostages and still fighting it out.

In a rousing address to soldiers a day after the killing of two commanders of the rebel alliance, Duterte said he would never again allow militants to stockpile so many weapons, but Marawi was now free and it was time to heal wounds and rebuild.

“I hereby declare Marawi City liberated from terrorist influence, that marks the beginning of rehabilitation,” Duterte, wearing a camouflage cap and dark sunglasses, said during his unannounced visit.

Isnilon Hapilon, who was wanted by the United States and was Islamic State’s Southeast Asian “emir,” and Omarkhayam Maute, one of two brothers central to the alliance, were killed in a targeted operation on Monday. Their bodies were recovered and identified, authorities said.

The 148-day occupation marked the Roman Catholic-majority Philippines’ biggest security crisis in years and triggered concerns that with its mountains, jungles and porous borders, the island of Mindanao could become a magnet for IS 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 airstrikes.

Duterte said the liberation was not a cause for celebration and later apologized to the people of Marawi for the destruction.

“We had to do it,” he said. “There was no alternative.”

Armed forces chief Eduardo Ano said the remaining gunmen were now a “law enforcement matter,” while military spokesman Restituto Padilla described them as “stragglers.”

“There is no way that they can get out anymore, there is no way for anyone to get in,” Padilla told news channel ANC.

Padilla said the military believed Malaysian operative Mahmud Ahmad was in Marawi, but it could not be certain. He said Mahmud was no threat.

“Dr. Mahmud is an academic, he’s not a fighter,” Padilla said. “We don’t feel he is a problem.”

But some security experts say otherwise and believe Mahmud, 39, a recruiter and fundraiser who trained at an al-Qaida camp in Afghanistan, could replace Hapilon as the IS point-man in Southeast Asia.

Another leader, Abdullah Maute, has yet to be accounted for. Intelligence indicated he died in an August airstrike, though no body was found.

Defense officials say the core leadership was key to recruiting young fighters and arranging for extremists from Indonesia, Malaysia, Singapore and beyond to join the push to carve out an East Asian “Wilaya,” or IS province.

Hapilon had teamed up with the moneyed Maute clan in their stronghold of Lanao del Sur, one of the Philippines’ poorest provinces, and brought with him fighters from his radical faction of Abu Sayyaf, a group better known for banditry.

Defense Secretary Delfin Lorenzana, who estimated Marawi operations to have cost 5 billion pesos ($97.5 million), said reconstruction could start in January.

“There are still stragglers and the structures are still unsafe because of unexploded ordnance and improvised explosive devices,” he said on radio.

The Marawi occupation set alarm bells ringing in the Philippines, with militants surprising security forces with their combat prowess, the volume of arms and ammunition they stockpiled and their ability to withstand intensive airstrikes aided by U.S. surveillance drones and technical support.