Manila: The Philippine military said militants fled from a primary school in the south on Wednesday, leaving behind 31 hostages unharmed, including 12 children, after a day-long gunbattle with troops.
There was no word of casualties in the incident at Pigcawayan town, which is about 190 km (120 miles) south of Marawi City, where fighting between government troops and pro-IS militants has entered its fifth week.
"The enemy made a hasty withdrawal, leaving behind 31 hostages, among them 12 youngsters," Brigadier General Restituto Padilla told Reuters. He said another 20 civilians who were trapped in the area because of the crossfire were also rescued.
Police said about 300 armed men from the Bangsamoro Islamic Freedom Fighters (BIFF) stormed the school early on Wednesday.
Padilla, however, said later only about 50 militants were involved.
Military officials were initially not certain if any hostages were taken and whether they included children.
Community leaders in the area were called in to help in negotiations to rescue the hostages, Padilla said.
"It's over ... but we're also on guard because they might carry out other attacks," said Padilla.
Abu Misry Mama, a spokesman for the BIFF, told Reuters that the militants had taken civilians to a safe place, away from any crossfire, and did not intend to hold them hostage.
Asked earlier if they would be freed, Mama said: "Yes. We're not kidnappers."
Both Pigcawayan and Marawi are on the large southern island of Mindanao.
Some members of the BIFF have joined militants from two more powerful Islamist factions, the Maute group and Abu Sayyaf, who occupied the town of Marawi a month ago and have been battling government forces there since.
But Padilla said the incident at Pigcawayan was not related to the fighting in Marawi.
"This has come from a group that has long committed harassments," he said.
Get your essential daily briefing delivered direct to your email inbox with our e-newsletter
The seizure of Marawi and the dogged resistance by the rebels there who have pledged allegiance to IS has alarmed Southeast Asian countries. Governments fear IS, on a backfoot in Iraq and Syria, is trying to set up a stronghold in the Muslim south of the mainly Roman Catholic Philippines that could threaten the whole region.