"It's already resolved," Brigadier General Restituto Padilla told reporters on Wednesday.
"They've withdrawn, they are no longer there. The school area is again safe."
However, Padilla also said the military was investigating whether five civilians were still being held by the militants. He said no children had been taken hostage.
Earlier, a spokesman for the militant group said they had taken civilians to a safe place after a gunfight erupted with troops and did not intend to hold them.
A police report said about 300 armed men, among them members of the Bangsamoro Islamic Freedom Fighters (BIFF), stormed a school in Pigcawayan town in North Cotabato province on Mindanao island and were holding some students captive.
Members of the BIFF were engaged in a gunbattle with the military, Chief Inspector Realan Mamon, the police chief at Pigcawayan, said in a radio interview.
Map of Cotabato Province, Philippines Source: SBS