The Philippine military said Islamist militants who had holed up in a primary school in the south early on Wednesday had retreated after a gunbattle with troops but were holding some civilians hostage.

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-Islamic State militants has entered its fifth week.

No students were taken hostage at the school, said Brigadier General Restituto Padilla, discounting reports that some children were being held. He said the militants had retreated from the school and troops were chasing them.

Another military spokesman, Captain Arvin Encinas, said the militants, who call themselves the Bangsamoro Islamic Freedom Fighters (BIFF), were holding some civilians hostage, but he was not sure how many.

"Definitely, they are holding hostages, that's why our soldiers are having difficulty because they are using them as human shields," Encinas said.

Police said about 300 armed men stormed the school early on Wednesday. Encinas, however, said later only 30 militants were involved.

Abu Misry Mama, a spokesman for the BIFF, told Reuters that the militants had taken civilians to a place safe, away from any crossfire, and did not intend to hold them hostage.

Asked if they would be freed, Mama said: "Yes. We're not kidnappers."

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.