MARAWI – Inside this lakeside city dotted with hundreds of mosques, a powerful militant designated by the Islamic State group (I.S.) as its leader in the Philippines has managed to unify a disparate group of gunmen under a single command.

Over the past week, his fighters have shown their muscle, withstanding a sustained assault by the Philippine military and increasing fears that the Islamic State group’s violent ideology is gaining a foothold in this country’s restive southern islands, where a Muslim separatist rebellion has raged for decades.

The army insists the drawn-out fight is not a true sign of the militants’ strength, and that the military has held back to spare civilians’ lives.

“They are weak,” Gen. Eduardo Ano, the military chief of staff, said of the gunmen, speaking at a hospital where injured soldiers were being treated. “It’s just a matter of time for us to clear them from all their hiding places.”

Still, the fighters have turned out to be remarkably well-armed and resilient.

Attack helicopters were streaking low over Marawi on Monday, firing rockets at militant hideouts, as heavily armed soldiers went house to house in search of fighters.

For nearly a week, the I.S. gunmen have held the Philippine army at bay, burning buildings, taking at least a dozen hostages and sending tens of thousands of residents fleeing. Officials say the commander, Isnilon Hapilon, who is one of Washington’s most-wanted militants, is still hiding somewhere in the city.

President Rodrigo Duterte declared martial law for 60 days in the south last week after the militants went on a deadly rampage in Marawi following a failed military raid to capture Hapilon.

In recent years, small militant groups have emerged in the Philippines, Indonesia and Malaysia and have begun unifying under the banner of the Islamic State group.

Jose Calida, the top Philippine prosecutor, said last week that Indonesians and Malaysians were among the fighters in Marawi, and that the violence on the large southern island of Mindanao “is no longer a rebellion of Filipino citizens.”

Rohan Gunaratna, a terrorism expert at Singapore’s S. Rarajatnam School of International Studies, believes that I.S. and the smaller regional groups are working together to show their strength and declare a Philippine province of the caliphate that I.S. says it created in the Middle East.

He said the fighting in Marawi, along with smaller battles elsewhere in the southern Philippines, may be precursors to declaring a province, which would be “a huge success for the terrorists.”

Last week, twin suicide bombings in Jakarta, Indonesia, claimed by I.S. killed three policemen. While Indonesia has been fighting militants since 2002, the rise of the Islamic State group has breathed new life into local militant networks and raised concern about the risk of Indonesian fighters returning home from the Middle East.

Experts have warned that as I.S. is weakened in Iraq and Syria, battered by years of U.S.-led attacks, Mindanao could become a focal point for regional fighters.

Southeast Asian fighters fleeing the Middle East “could look to Mindanao to provide temporary refuge as they work their way home,” said a report late last year by the Jakarta-based Institute for Policy Analysis of Conflict, predicting a high risk of regional violence. Marawi is regarded as the heartland of the Islamic faith on Mindanao island.

The fighters’ support network in Marawi remains unclear, though the power of one militant group — the Mautes — has grown in recent years. Led by members of the city’s Maute clan, the group has become increasingly active in a number of towns across Lanao del Sur province, where Marawi is located, and has been instrumental in fighting off government forces over the past week.

Muslim rebels have been waging a separatist rebellion in the south of the predominantly Roman Catholic nation for decades. The largest armed group dropped its secessionist demands in 1996, when it signed a Muslim autonomy deal with the Philippine government. Amid continuing poverty and other social ills, restiveness among minority Muslims has continued.

Hapilon is an Islamic preacher and former commander of the Abu Sayyaf militant group who pledged allegiance to I.S. in 2014. He now heads an alliance of at least 10 smaller militant groups, including the Maute.

Maute militants flew an I.S. flag in one of the city’s mosques last year, a local resident said, speaking on condition of anonymity, fearing for his safety. He said they also pressured local Muslim preachers, accustomed to a less-strict form of Islam, not to speak out against them.

But Acmad Aliponto, a 56-year-old court sheriff who decided not to flee the city, said that while the militants were well-armed, he believes they have little local support, and that the recent violence could turn more people against them.

“In the end their relatives and everyday people may be the ones who will kill them,” he said. “Look at what they did. So many were affected.”

JIM GOMEZ