Armed Islamic militants have killed 29 students and an English teacher in an attack on a boarding school in northeastern Nigeria.

Survivors being treated for burns and gunshot wounds said some students were burned alive in the attack on Saturday which has been blamed on a radical terror group.

Gunmen, believed to be from Islamist sect Boko Haram, stormed the premises of Government Secondary School in the town of Mamudo in Yobe state at around 3am, setting fire to parts of the complex.

Dozens of children from the 1,200-student school escaped into the bush and have not been seen since.

Parents rushed to the school and screamed in anguish as they tried to identify the charred and dead bodies of the victims.

Mohammed Musa, who taught English at the school, died after he was shot in the chest.

One 15-year-old, who survived the attack, told of how he awoke to find one of the attackers pointing a gun at him.

Speaking at Potsikum General Hospital, Musa Hassan said: "We were sleeping when we heard gunshots. When I woke up, someone was pointing a gun at me."

He put up his hands in defence and was shot in his right hand, the one he uses to write with, and lost four fingers.

The child said the gunmen came armed with jerry cans of fuel that they used to torch the school's administrative block and one of the hostels.

"They burned the children alive," he added.

Farmer Malam Abdullahi found the bodies of two of his sons, a 10-year-old shot in the back as he apparently tried to run away, and a 12-year-old shot in the chest.

He said he planned to withdraw his three remaining sons from another school nearby.

"That's it, I'm taking my other boys out of school," he said.

He complained there was no protection for students despite the deployment of thousands of troops since the government declared a state of emergency mid-May in three northeastern states .

"It's not safe," he said. "The gunmen are attacking schools and there is no protection for students despite all the soldiers," he added.

It is the deadliest of three attacks on schools since the military launched its offensive to try to crush Boko Haram. The group's nickname translates as "Western education is sinful" in the northern Hausa language.

Suspected Islamist militants opened fire on a school in Nigeria's northeastern city of Maiduguri last month, killing nine students, and a similar attack on a school in the city of Damaturu killed seven just days earlier.

Dozens of schools have been torched and unknown scores of students killed among more than 1,600 victims slain by extremists since 2010.

Militants have increasingly targeted civilians, including health workers on vaccination campaigns, teachers and government workers, while farmers have been driven from their land.

President Goodluck Jonathan declared a state of emergency on May 14, and deployed thousands of troops to halt the insurgency, acknowledging that militants had taken control of some towns and villages.

Nigerian forces say they have wrest back control of the remote northeast from Boko Haram, destroying key bases and arresting scores of suspects.

However, the military crackdown has pushed many militants into hiding.