Muslim rebels raided a southern Philippine village and positioned themselves in a school as they engaged troops in a gunbattle early Wednesday that officials said may be an attempt to disrupt the massive military offensive in besieged Marawi city. They took five civilians as shields during their retreat later in the morning, the military said.

Police Chief Inspector Realan Mamon told The Associated Press by telephone that gunmen from the Bangsamoro Islamic Freedom Fighters raided the village of Malagakit in North Cotabato province at dawn and engaged government forces in a firefight. Villagers fled to safety.

"I got a report that the attackers occupied an elementary school but it's not sure whether people were trapped in the fighting or were taken hostage," said Mamon, the police chief of Pigkawayan town, where Malagakit is located. The Malagakit school was closed at the time of the attack.

Military spokesman Brig. Gen. Restituto Padilla said the gunmen targeted an army outpost and a patrol base of pro-government militiamen, who fired back and were later reinforced by army troops. The attackers apparently were withdrawing, and took five civilians as human shields, none of them students, Padilla said.

"We are still verifying if they have not yet been freed," he said, adding that a spokesman for the attackers has said they did not mean to take hostages and the civilians were taken only to help cover their withdrawal.

Padilla said no one has been reported hurt, the situation has been addressed, and the gunmen have retreated.

He said it was possible the attack was intended to disrupt an ongoing military offensive against a separate group of militants aligned with the Islamic State group who laid siege on Marawi city. Some commanders of the Bangsamoro Islamic Freedom Fighters have also pledged allegiance to the Islamic State group like the militants fighting in Marawi, which is located in Lanao del Sur province.

"If this is a diversionary move, it's not the first by these BIFF gunmen," Padilla said. "They have tried to attack more than once and all have been thwarted."

Last month, about 500 militants laid siege on Marawi, a mosque-dotted center of the Islamic faith in the country's south, after a failed attempt by government forces to capture a top militant suspect. Philippine troops, backed by airstrikes and artillery, remain involved in the offensive to wrest back control of villages and the business district. At least 258 militants, 65 soldiers and policemen and 26 civilians have been killed.

The U.S. military in recent weeks deployed a P3 Orion aircraft to provide surveillance and intelligence to troops battling more than 100 gunmen holding an unspecified number of hostages in four remaining Marawi villages. President Rodrigo Duterte, despite having an antagonistic stance toward U.S. security policies, has acknowledged the U.S. assistance is helping save lives, as he faces his most serious crisis in his yearlong presidency.

Duterte has said politicians, including some linked to the illegal drug trade, may have covertly backed the militants, who stockpiled arms and supplies before launching their audacious plot in Marawi. The attack has sparked fears that the Islamic State group, while losing territory in Syria and Iraq, may be gaining a foothold in Southeast Asia by supporting local militants with money, training and weapons.

Duterte visited hundreds of displaced Marawi villagers huddled in an evacuation camp in Iligan city, near Marawi, Tuesday and apologized for their being displaced by the Marawi crisis during the Muslim fasting month of Ramadan.

"I would like to say to the Maranao people that I am very, very, very sorry that this happened to us," Duterte told the crowd, referring to the ethnic group to which most Marawi residents belong.

Duterte asked the displaced villagers "to forgive my soldiers, the government, including myself for declaring martial law." ''I have no choice, Marawi is being destroyed. I have to drive them out," he said.

Duterte declared martial law in the entire southern region to deal with the Marawi crisis. Officials have said the government would temporarily stop offensives against communist guerrillas to reciprocate a similar plan by the insurgents and to allow troops to focus on crushing the Marawi uprising that has dragged on for a month.