Muslim rebels withdrew from a southern Philippine village Wednesday after security forces moved rapidly to prevent another crisis amid a monthlong militant siege in nearby Marawi city, officials said.

About 300 gunmen stormed the village of Malagakit in North Cotabato province at dawn Wednesday and engaged government forces in a firefight. There've been no reports of casualties and hundreds of villages fled to safety, but military spokesman Brig. Gen. Restituto Padilla said the gunmen took an unspecified number of civilians to cover their retreat.

Police said the attackers belonged to the Bangsamoro Islamic Freedom Fighters, one of several Muslim rebel groups active in the south. Militant spokesman Abu Misry Mamah acknowledged in a radio interview that his group staged the attack but said they did not intend to take hostages.

The gunmen occupied a grade school building as they clashed with government forces, said Chief Inspector Realan Mamon, the police chief of Pigcawayan township, where Malagakit is located. The school was closed at the time of the attack.

"They've withdrawn from the area, they're no longer there. The school area is safe," Padilla told a news conference in Manila, adding troops were pursuing the attackers.

The rebels, hiding in the marshy heartland of the country's southern region, broke off from the largest Muslim rebel group several years ago partly to protest peace talks with the government. The breakaway rebels, however, have been weakened by battle setbacks and some of its commanders have tried to align themselves with the Islamic State group in the hope of securing funding from the Middle East-based group, according to the military.

Padilla said it was possible the attack was intended to disrupt an ongoing military offensive against a separate group of IS-aligned militants who laid siege May 23 in Marawi city in Lanao del Sur province, about 55 kilometers (35 mile) away.

"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 seized Marawi, a mosque-dotted center of the Islamic faith in the south of the predominantly Roman Catholic nation. The attack followed an army and police raid on a hideout that failed to capture a top militant suspect. Philippine troops, backed by airstrikes and artillery, have been fighting street battles to wrest back control of the city's business district.

At least 258 militants, 65 soldiers and police and 26 civilians have been killed and more than 300,000 villagers have fled from Marawi and outlying towns.

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 Marawi. President Rodrigo Duterte, despite having an antagonistic stance toward Washington, has acknowledged the U.S. assistance is helping save lives.

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 declared martial law in the entire Mindanao region to deal with the Marawi crisis.