At least 21 people have died in fighting that erupted late Tuesday, when the army raided the Marawi hideout of Isnilon Hapilon, who is on Washington's list of most-wanted terrorists and has a $5 million bounty on his head.
The operation went wrong as the militants called in reinforcements and swept through the mostly Muslim city of 200,000 people. Hapilon's whereabouts were not clear, but there was no indication he was captured in the raid.
President Rodrigo Duterte declared martial law across the southern third of the nation - home to some 22 million people - and warned he may expand it nationwide.
He vowed to be "harsh."
"If I think that you should die, you will die," he said Wednesday. "If you fight us, you will die. If there is open defiance, you will die. And if it means many people dying, so be it."
As details of the attack in Marawi city emerged, fears mounted that the largest Roman Catholic nation in Asia could be falling into a growing list of countries grappling with the spread of influence from the Islamic State group in Syria and Iraq.
Thousands of people were fleeing the city Thursday, jamming their belongings into cars. Plumes of black smoke rose in the distance and two air force helicopters could be seen flying over the city center.
Mohammad Usman, a 49-year-old Marawi resident, said some people are likely trapped with no way out.
"At night we can hear the gunfire. I'm just praying that the bullets will not find its way to my house and hit us," he said as he left the city. "I hope that the bombs will not land nearby and harm us."
Although much of the city is sealed off, disturbing details were trickling out.
Duterte said a local police chief was stopped at a militant checkpoint and beheaded. Military chief of staff Gen. Eduardo Ano said the militants erected Islamic State flags at several locations.
Marawi Bishop Edwin de la Pena said the militants forced their way into the Marawi Cathedral and seized a Catholic priest, 10 worshippers and three church workers.
Martial law allows Duterte to use the armed forces to carry out arrests, searches and detentions more rapidly. He has repeatedly threatened to place the south, the scene of decades-long Muslim separatist uprisings, under martial law. But human rights groups have expressed fears that martial law powers could further embolden Duterte, whom they have accused of allowing extrajudicial killings of thousands of people in his crackdown on illegal drugs.
Hapilon, an Arabic-speaking Islamic preacher known for his expertise in commando assaults, pledged allegiance to the Islamic State group in 2014. He is a commander of the Abu Sayyaf militant group and was wounded by a military airstrike in January.
While pursuing peace talks with two large Muslim rebel groups in the south, Duterte has ordered the military to destroy smaller extremist groups which have tried to align with the Islamic State group.
At least one of those smaller groups, the Maute, was involved in the Marawi siege. It's one of less than a dozen new armed Muslim groups that have pledged allegiance to the Islamic State and formed a loose alliance, with Hapilon reportedly designated as the alliance's leader.
Political analyst Ramon Casiple said the Maute is a clan-based group with members in Marawi who came to Hapnilon's assistance, with some directly assisting in the fighting and others fanning out to different parts of the city, setting up checkpoints and burning some buildings and taking hostages from the cathedral.
"It is difficult to root out because they are from there," he said. "The Mautes are embedded in the population."
The group has been blamed for a bombing that killed 15 people in southern Davao city, Duterte's hometown, last September and a number of attacks on government forces in Lanao, although it has faced setbacks from a series of military offensives.
Last month, troops backed by airstrikes killed dozens of Maute militants and captured their jungle camp near Lanao del Sur's Piagapo town. Troops found homemade bombs, grenades, combat uniforms and passports of suspected Indonesian militants in the camp, the military said.
Cerojano reported from Manila.
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.