Pro-ISIS rebels continued to hold several hostages in a southern Philippine school on Wednesday despite earlier reports that the insurgents have retreated from the building, military officials said.

About 200 to 300 gunmen from Bangsamoro Islamic Freedom Fighters retreated to the Malagakit grade school building after seeking retreat from government forces, local army spokesman Capt. Arvin Encinas. The gunmen seized villagers in North Cotabato province Wednesday evening while trying to dodge gunfire from government forces.

Military spokesman Brig. Gen. Restituto Padilla initially reported the rebels withdrew from the school after reinforcement troops arrived. He later said the troops reported that the rebels were still held up at the building, with other insurgents returning to the area.

Rebel spokesman Abu Misry Mamah acknowledged in a radio interview that his group staged the attack, but said they only took hold of some villagers to protect them from the government forces.

Padilla said the rebels may have launched the attack on the village in order to diverge focus on an ongoing military offensive against a separate group of IS-aligned militants who laid siege May 23 in Marawi in Lanao del Sur province, also in the country's south.

The Bangsamoro Islamic Freedom Fighters, mostly encamped 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.

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

The Associated Press contributed to this report.