The gunmen, thought to be members of rebel sect Boko Haram, attacked one hostel, took some students outside before killing them and shot others trying to flee, people at the scene told Reuters.

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. Several schools, seen as the focus of Western-style education and culture, have been targeted.

President Goodluck Jonathan described the assault as "the creation of the devil" and suggested it might be time to change tactics against the rebels, without going into details.

"They started gathering students into groups outside, then they opened fire and killed one group and then moved onto the next group and killed them. It was so terrible," said one surviving student Idris, who would only give his first name.

"They came with guns around 1 am (2400 GMT) and went directly to the male hostel and opened fire on them. The college is in the bush so the other students were running around helplessly as guns went off and some of them were shot down," said Ahmed Gujunba, a taxi driver who lives by the college.

Bodies were recovered from dormitories, classrooms and outside in the undergrowth on Sunday, a member of staff at the college said, asking not to be named.

Boko Haram and spin-off Islamist groups like the al-Qaeda-linked Ansaru have become the biggest security threat in Africa's second largest economy and top oil exporter.

Western governments are increasingly worried about the threat posed by Islamist groups across Africa, from Mali and Algeria in the Sahara, to Kenya in the East, where Somalia's al-Shabaab fighters killed at least 67 people in an attack on a Nairobi shopping mall a week ago.

A Reuters witness counted 40 bloody corpses piled on the floor at the main hospital in Yobe state capital Damaturu on Sunday, mostly of young men believed to be students.

The bodies were brought from the college, which is in Gujba, a rural area 30 miles (50km) south of Damaturu and around 130 miles from Nigerian borders with Cameroon and Niger.

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

Thousands have been killed since Boko Haram launched its uprising 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 Jonathan declared a state of emergency in three northeastern states 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.

"When I declared a state of emergency things calmed down. Now they are looking for soft targets. If the drum is changing, we must change steps," Jonathan said in a speech in the capital Abuja.

"The people they killed they don't even know them. This is the creation of the devil. No Boko Haram or any group can frustrate this country. I assure Nigerians we'll do what is required to protect them," he added.

In July, suspected Boko Haram militants killed 27 students and a teacher at a school in Potiskum, a town about 30 miles from the site of Sunday's attack.

Several hundred people have died in assaults over the past few weeks. Some observers say the army offensive has only succeeded in pushing attacks away from well-guarded large towns and cities into vulnerable rural areas.

Boko Haram's insurgency is also putting pressure on the economy of Africa's most populous nation. Nigeria's security spending has risen to more than 1 trillion naira per year, or around 20 percent of the federal budget.