More than 40 people, including many children, have died in an suspected Islamist militant attack on a school in north-east Nigeria.

Survivors say the militants doused a dormitory in petrol and set it alight as students slept at the secondary school in Yobe state.

Authorities say the attackers were Islamists from Nigeria's Boko Haram insurgent group, which has been behind a spate of school attacks in the region.

Many of the victims were taken to a hospital at Potiskum with burns and gunshot wounds.

"We received 42 dead bodies of students and other staff of Government Secondary School [in] Mamudo last night," Haliru Aliyu of the Potiskum General Hospital said.

"Some of them had gunshot wounds while many of them had burns and ruptured tissues.

Mr Aliyu says security personnel are combing the bushes around the school in search of wounded students who were believed to have escaped.

"So far six students have been found and are now in the hospital being treated for gunshot wounds," he said.

Mamudo is some five kilometres from Potiskum, the commercial hub of Yobe State which has been a flashpoint in the Boko Haram insurgency in recent months.

A local resident, who did not want to be named, has confirmed the attack.

"It was a gory sight," he said.

"People who went to the hospital and saw the bodies shed tears.

"Some of them had parts of their bodies blown off."

He says the attack was believed to be a reprisal by the Boko Haram Islamists for the killing of 22 sect members during a military raid in the town of Dogon Kuka on Thursday.

Violence linked to the Boko Haram insurgency has left some 3,600 people dead since 2009, including killings by the security forces.

Boko Haram - which means "western education is evil" - has killed hundreds of students in attacks on schools in the tense region in recent months.

Violence linked to the Boko Haram insurgency has left some 3,600 people dead since 2009, including killings by the security forces, who have come under major criticism for alleged abuses.

ABC/wires