Suspected Islamic extremists attacked an agricultural college in the dead of night, gunning down dozens of students as they slept in dormitories and torching classrooms, the school's provost said — the latest violence in northeastern Nigeria's ongoing Islamic uprising.

The attack, blamed on the Boko Haram extremist group, came despite a 4½-month-old state of emergency covering three states and one-sixth of the country. It and other recent violence have led many to doubt assurances from the government and the military that they are winning Nigeria's war on the extremists.

Provost Molima Idi Mato of Yobe State College of Agriculture told The Associated Press that there were no security forces protecting the college. Two weeks ago, the state commissioner for education had begged schools and colleges to reopen and promised they would be guarded by soldiers and police.

Idi Mato said as many as 50 students may have been killed in the assault that began at about 1 a.m. Sunday in rural Gujba. "They attacked our students while they were sleeping in their hostels. They opened fire at them," he said, adding that most victims were aged between 18 and 22.

Soldiers recovered 42 bodies and transported 18 wounded students to Damaturu Specialist Hospital, 40 kilometres north, said a military intelligence official who insisted on anonymity because he was not authorized to speak to the press.

Two of the wounded later died, said Adamu Usman, a survivor from Gujba who was helping at the hospital.

President Goodluck Jonathan condemned the attack in a televised "chat with the media" Sunday night, and questioned the motives of Boko Haram, which wants to impose Islamic law across Nigeria. He said he wondered whether the victims were Muslim or Christian.

Usman said almost all those killed were Muslims, as is the majority of the college's student body.

Assault likened to Nairobi mall attack

Jonathan likened the assault to that on Nairobi's premier shopping mall last week, where Islamic extremists from Somalia's al-Shabab movement killed 67 civilians — but only after allowing many Muslims to leave. Boko Haram has said some of its fighters trained with al-Shabaab in Somalia.

Boko Haram leader Abubakar Shekau has said in video addresses that his group wants to end democracy in Nigeria and allow education only in Islamic schools. Boko Haram means "Western education is forbidden."

Its uprising poses the biggest security challenge in years to this country. Nigeria is Africa's biggest oil producer and its most populous nation with more than 160 million people — almost equal numbers of which are Muslims and Christians.

Boko Haram militants have killed more than 1,700 people since 2010.

"Sometimes you need courage" to confront such challenges, Jonathan said, accusing the extremists of choosing soft targets to embarrass his government.

Gov. Ibrahim Gaidam of Yobe state, where the killings occurred, indicated that the military crackdown is ineffective.

"Although there is (an) increase in troop movement and military hardware deployment in the northeast, people are yet to see the kind of action on the ground that effectively nips criminal and terrorist activities in the bud," he said in a statement.

Attackers familiar with college layout

The extremists rode into the college in two double-cabin pickup all-terrain vehicles and on motorcycles, some dressed in Nigerian military uniforms, a surviving student, Ibrahim Mohammed, told the AP. He said they appeared to know the layout of the college, attacking the four male hostels but avoiding the one hostel reserved for women.

"We ran into the bush, nobody is left in the school now," Mohammed said.

Wailing relatives gathered outside the hospital morgue, where workers laid out bloody bodies in an orderly row on the lawn for family members to identify loved ones.

One body had its fists clenched to the chest in a protective gesture. Another had hands clasped under the chin, as if in prayer. A third had arms raised in surrender.

Mato confirmed the school's other 1,000 enrolled students have fled the college.

Most schools in the area closed after militants on July 6 killed 29 pupils and a teacher, burning some alive in their hostels, at Mamudo outside Damaturu.

U.S. President Barack Obama on Tuesday described Boko Haram as one of the most vicious terrorist organizations in the world, speaking at a meeting with Jonathan at which both reaffirmed their commitment to fight terrorism.

30,000 fled to neighbouring countries

The Islamic extremists have killed at least 30 other civilians in the past week, including a pastor and his son. And the military said it killed more than 100 militants and lost 16 soldiers in an attack on an extremist stronghold Sept. 21-22.

Human rights groups have accused Nigeria's military of summary killings of civilians in reprisal attacks and no one knows the fate of hundreds of people detained as suspected militants.

Meanwhile, farmers and government officials are fleeing threats of imminent attacks from Boko Haram in the area of the Gwoza Hills, a mountainous region with caves that shelter the militants despite repeated aerial bombardments by the military.

A local government official said there had been a series of attacks in recent weeks. The official, who spoke on condition of anonymity because he feared for his life, said Gwoza town was deserted when he visited it briefly under heavy security escort on Thursday.

He said militants had chased medical officers from the government hospital in Gwoza, which had been treating some victims of attacks, and torched three public schools.

More than 30,000 people have fled to neighbouring Cameroon and Chad and the uprising combined with the military emergency has forced farmers from their fields and vendors from the markets.

The attacks come as Nigeria prepares to celebrate 53 years of independence from Britain on Tuesday and amid political jockeying in the run up to presidential elections next year. Many northern Muslim politicians say they do not want another term for Jonathan, who is from the predominantly Christian south.