Suspected Islamists shot dead nine students as they sat an exam in an attack on a private school in Maiduguri, northeast Nigeria, local people said on Tuesday.
The attack, in a region that is a stronghold of the Islamist rebel group Boko Haram, happened on Monday in the Jajeri suburb of the city, they said.
Mohammed Saleh, a relative of one of the deceased students, said school officials had told him that the attack happened soon after the end-of-year exam had started.
"Nine of the students died instantly," he said, blaming members of Boko Haram.
David Buba, a student at the school who was on the premises when the attack happened, told AFP he had lost a friend in the attack.
"I was within the school premises on Monday afternoon when I started hearing gunshots," he said.
"I initially thought it was outside the school but when I saw people running, I was confused and hid somewhere in fear until 30 minutes later when corpses of our students were brought out of the exam hall."
A security force spokesman could not be reached to confirm the attack.
Overnight Sunday to Monday, suspected Boko Haram gunmen opened fire on a secondary school in Damaturu, in the neighbouring state of Yobe to the west, killing seven students and two teachers.
Two of the attackers were also killed, said the army.
Boko Haram, whose name roughly translates as "Western education is sin," has carried out multiple attacks on schools in violence-torn northeast Nigeria.
The group has said it is fighting to create an Islamic state in the country's mainly Muslim north.
In May, the army launched a major offensive against the group in Nigeria's three northeastern states: Borno, Yobe and Adamawa, and imposed a state of emergency.
In an audio message obtained by AFP on Tuesday, Abu Zinnira, who claimed to speak for Boko Haram, accused the youth of Maiduguri and Yobe of collaborating with the authorities.
"We hereby declare an all-out war on you because you have formed an alliance with the Nigerian military and police to fight our brethren," he said.
Speaking in Hausa, the most common language in northern Nigeria, he added: "We call on any parent that values the life of his son to stop him from exposing our members otherwise he is dead."
A statement issued on Monday by army spokesman brigadier general Chris Olukolade praised the initiative of some local people, "...particularly youths organized into vigilante groups to join the efforts to fish out the terrorists within their communities."
The Boko Haram insurgency has left some 3,600 people dead since 2009, according to Human Rights Watch.
That figure includes killings by the security services, who rights groups have accused of carrying out widespread abuses.