An attack Sunday by Boko Haram Islamists who opened fire on students while they were sleeping in a college dormitory has killed at least 28 people, a hospital source told AFP.

"We have so far received 28 bodies. We have been asked to expect more," said the official at the Damaturu Specialist Hospital, referring to those killed at the College of Agriculture in Gujba, some 30 kilometres (18 miles) from Damaturu, capital of the northeastern Yobe state.

The early morning assault targeted the College of Agriculture in the town of Gujba in Yobe state, area military spokesman Lazarus Eli said.

It was carried out by "Boko Haram terrorists who went into the school and opened fire on students," while they were sleeping, he added.

A police source, who requested anonymity, told AFP that initial reports indicated the death toll could be high but he was not prepared to discuss figures.

Gujba is roughly 30 kilometres (18 miles) from the state capital of Damaturu.

Yobe has seen a series of brutal attacks targeting students in recent months, all blamed on Boko Haram.

The worst occurred in July in the town of Mamudo, where the Islamists threw explosives and sprayed gunfire into dormitories in the middle of the night, killing 41 students.

The name Boko Haram means 'Western education is forbidden' and the group has repeatedly attacked schools, universities and colleges during its four-year insurgency.

The military has described the spate of recent school attacks as a sign of desperation by the Islamists, claiming they only have the capacity to hit soft targets.

The defence ministry has said that an offensive launched against Boko Haram in mid-May has decimated the group and scattered their fighters across remote parts of the northeast.

While many of the recent attacks have occurred in more remote areas, often targeting defenceless civilians, the unchecked killing has cast doubt on the success of the military's campaign.

The northeast remains under a state of emergency imposed on May 14.

Scores have been killed this month, including in the northeastern town of Benisheik in Borno state, where at least 142 people were slaughtered by presumed Boko Haram fighters who came disguised as soldiers, set up checkpoints and fired on motorists and bystanders.

Some of the recent violence has targeted vigilante groups which have formed to help the military.

Boko Haram has said it is fighting to create an Islamic state in Nigeria's mainly Muslim north, but the group is believed to made up of different factions with varying aims.

A toll earlier this year said the conflict is estimated to have cost more than 3,600 lives, including killings by the security forces. The current figure is likely much higher.

Nigeria is Africa's most populous country and top oil producer.