A major Philippine military offensive has killed 24 suspected local sympathizers of the Islamic State group and captured their remote southern stronghold, where troops raised the national flag on Tuesday, the military said.

Six soldiers were killed and a dozen others were wounded in the weeklong campaign that involved about 2,000 military personnel in Butig town in Lanao del Sur province, Armed Forces of the Philippines spokesman Brig. Gen. Restituto Padilla said.

Army generals turned over control of the captured militant stronghold in Poktan village to the Butig town mayor after the flag-raising ceremony, which was held near where leaders of the extremist group identified as Omar and Abdullah Maute used to live, Padilla said.

About 40 militants attacked an army camp in Butig on Feb. 20 in the predominantly Muslim region about 840 kilometers (520 miles) south of Manila. More militants, some wearing black arm and head bands with Islamic State group-style symbols, later joined in the fighting, prompting the military to deploy three battalions of troops backed by assault helicopters and artillery fire, according to the military.

Aside from 24 militant deaths, which were confirmed by the military, nine other gunmen may have been killed, Padilla said, citing intelligence and accounts from villagers.

"Our doctrine is to resolve the conflict in the shortest possible time with the full application of military resources," Padilla said. With the backing of provincial government officials, he said the rapid military offensive helped stop "the spread of extremism."

More than 30,000 residents of 10 villages were displaced by the fighting, he said.

Troops were clearing battle sites and pursuing fleeing militants.

The militants initially were affiliated with an Indonesian terror suspect known only as Sanusi who was killed in Marawi city in the volatile region in 2012. They later used black flags and arm and head bands with Islamic State group symbols in an attempt to capture the attention of the Middle East-based terrorist group and possibly secure funding, military officials said.

The main Muslim rebel group, the Moro Islamic Liberation Front, has a large camp in the hinterlands of Butig, but the insurgents, who signed a peace deal with the government in 2014, backed away to avoid being drawn into the fighting and helped guide fleeing residents to safety, Padilla said.

There has been speculation that some Moro Islamic Liberation Front insurgents backed the militants in the clashes in protest after their peace agreement with the government stalled. But Padilla said those Moro rebel front insurgents may have been relatives of the militants belonging to the extremist group led by the Maute brothers, who are believed to have perished in the fighting.