Around 40 students have been shot dead by suspected Islamist militants, who stormed a college in northeastern Nigeria.

The gunmen, thought to be members of Boko Haram, attacked a hostel overnight in Gujba, a rural area 50km south of Damaturu.

Some people were shot dead as they slept, while others were brought outside before being killed. Some were shot as they tried to flee.

One surviving student said the gunmen arrived at about 1am (local time), went directly to the male hostel and opened fire.

Bodies were recovered from dormitories, classrooms and outside in the undergrowth, a member of staff at the college told reporters.

A Reuters witness counted 40 bodies piled on the floor at the main hospital in Yobe state capital Damaturu, mostly of young men.

State police commissioner Sanusi Rufai said he suspected Boko Haram was behind the attack, but gave no details.

Boko Haram, which wants to establish an Islamic state in northern Nigeria, has intensified attacks on civilians in recent weeks in revenge for a military offensive against its insurgency.

Thousands have been killed since Boko Haram launched it urprising in 2009, turning itself from a clerical movement opposed to Western culture into an armed militia with growing links to al- Qaeda's West African wing.

President Goodluck Jonathan declared a state of emergency in three northeastern state in May, including Yobe, and ordered a military offensive to crush Boko Haram's insurgency.

There was an initial lull in the violence as Islamists fled bases in cities, forests and mountains.

Then the militants began revenge attacks on schools, security forces and civilians believed to be helping them.

Several hundred people have died in assaults over the past few weeks.