The militants locked the door of one dormitory where male students were sleeping and then set it ablaze, slitting the throats of those who tried to clamber out of windows and gunning down those who ran away, said teacher Adamu Garba.
Some students were burned alive in the attack that began around 2 a.m., he said.
Bego said the entire complex of the relatively new school had been burned out by firebombs — six dormitories, the administrative building, staff quarters, classrooms, a clinic and the kitchen.
The governor would be asking questions about why the school apparently was left unprotected, he said.
"The community complained to the governor that yesterday the military were withdrawn and then the attack happened," he said. A group of about eight soldiers manned the checkpoint when an AP reporter visited recently, and the nearest military base was a unit of about 30 soldiers in Buni Gari town, 2 kilometers (1.2 miles) away.
But soldiers from Damaturu did not arrive until noon, hours after the attackers had finished their work and taken off, according to community leaders who said they buried the bodies of 29 victims. Most appeared to be between 15 and 20 years old, Bego said.
Military spokesman Eli Lazarus had confirmed the attack but said he could not give an exact death toll because soldiers still were gathering corpses. He could not immediately be reached to comment on charges about the abandoned roadblock.
Nigeria's military has reported arresting several soldiers accused of aiding and passing information to extremists of the terrorist network of Boko Haram — the nickname means "Western education is forbidden." A senator also has been accused of similar charges.
President Goodluck Jonathan on Monday night dismissed charges the military is losing the war to halt the 4-year-old Islamic uprising in the northeast of Africa's biggest oil producer.
He suggested he could withdraw the military from Borno state and see how long its governor, Yashim Shettima, could remain in his official residence. Shettima had flown to Abuja, the capital, last week to tell Jonathan that Boko Haram are "better motivated and better armed."
Jonathan said the Boko Haram attacks are "quite worrisome" but that he is sure "We will get over it."
Tens of thousands of Nigerians have lost family members, houses, businesses, their belongings and livelihoods to the rebellion and the fallout from a military state of emergency by soldiers accused of gross human rights violations including setting ablaze entire villages and summary executions of suspects.
Tuesday's attack is the latest in a string of deadly attacks — more than 300 civilians killed this month alone.
Jonathan said the military has enjoyed "some successes." Entire towns and villages were under the sway of Boko Haram when Jonathan declared a state of emergency in May. The military quickly forced the insurgents out of urban areas, only to have them regroup in forests and mountain caves where it has proved difficult to flush them out.
The military said recent attacks are perpetrated by militants who escaped a sustained aerial bombardment and ground assaults on their forest hideouts along the border with Cameroon, an offensive begun after Jonathan last month fired and replaced his entire military command. On Saturday, the military announced it had closed hundreds of kilometers (miles) of the border with Cameroon to prevent militants using it as an escape hatch and launch pad for attacks.