* Boko Haram have killed 46 students in four school attacks
* Islamists reject Western education as sacrilege
* Military offensive has weakened the insurgency
They crept up to the school under cover of darkness, armed with petrol and automatic weapons.
Most of the teachers and pupils had fled, but some students, one teacher and headmaster Adanu Haruna were still in the compound, one of many rural boarding schools in Nigeria surrounded by forest and farmland.
"They made the students line up and strip naked, then they made the ones with pubic hair lie face down on the ground," Haruna said, eyes wide with horror at describing the attack on the iron-roofed school built by British colonisers in the 1950s.
"They shot them point blank then set the bodies on fire."
The Mamudo government school, charred and smelling of scorched blood after 22 students and a teacher were killed there in the July 6 attack near Potiskum in Nigeria's northeast, was the fourth to be targeted by suspected Boko Haram militants in less than a month.
The attacks reveal much about the rebels who are fighting to revive a medieval Islamic caliphate in northern Nigeria, the type of state they are seeking to establish and the impact of their efforts to do so on the African economic powerhouse.
In a video uploaded to the Internet on Saturday, Boko Haram's purported leader Abubakar Shekau denied ordering the latest killings, saying Boko Haram does not itself kill small children, but he praised attacks on Western schools.
"We fully support the attack on school in Mamudo, as well as on other schools," he said. "Western education schools are against Islam ... We will kill their teachers."
Boko Haram, a nickname which translates roughly as "Western education is sinful", formed around a decade ago as a clerical movement opposed to Western influence, which the sect's founder, Mohammed Yusuf, said was poisoning young minds against Islam.
Yet security forces and politicians were the main targets of the armed revolt it started after Yusuf's killing in a 2009 military crackdown that left 800 people dead.
Since those days Boko Haram has splintered into several factions, including some with ties to al Qaeda's Saharan wing, which analysts say operate more or less independently, despite Shekau's loose claim to authority over them.
Before June, there had been only a handful of attacks on the Western-style schools it so despises.
An offensive against the insurgents since President Goodluck Jonathan declared a state of emergency in three remote northern states in May, wresting control of the far northeast from Boko Haram and pushing its fighters into hiding, has changed that.
Across northeastern Nigeria, schools are emptying out, threatening further radicalisation and economic decline in a region left behind by the country's oil-rich Christian south.
Nassir Salaudeen, a teacher whose son was killed in a strike on Damaturu government school on June 16, the first of the wave of recent attacks, said he had put all his efforts into his boy's education in the hope he would get a good job.
"They killed him in cold blood, just because he was a student and his father a teacher," a tearful Salaudeen said. "I regret ever being educated."
For some, the school attacks are a sign the offensive has weakened the Islamist group, which is still seen as the main security threat to Africa's leading oil and gas producer.
"Given the security clampdown, many of the places like police stations or the military are getting harder for Boko Haram to hit," said Kole Shettima, chairman of the Centre for Democracy and Development. "Schools are soft targets."
But the attacks also reflect a radical ideology that resents modernity and yearns to wind back the clock to an era before West African lands were conquered by Europeans.
Centuries ago northern Nigeria, like much of West Africa, was ruled by Islamic empires feeding off trans-Saharan trade routes connecting Africa's forested interior with its Mediterranean coast.
Boko Haram rarely gives statements to the media. But the little it has said suggests it wants to restore those glory days.
Last year, the sect said it wanted to revive the 19th century caliphate of Usman Dan Fodio, an Islamic scholar who threw off corrupt Hausa kings and established strict Sharia law.
When Britain established Nigeria as a territory, it agreed to spare the largely Muslim north's leaders the activities of missionaries, who brought Christianity but also education and literacy that gave the south a head start over the north.
The north was able to retain its Islamic culture but at the cost of suffering economically; political and economic power has shifted to the south and the education gap has played a role in that growing discrepancy.
A lack of education and high youth unemployment has also helped Boko Haram's Islamist ideology to thrive.
"Boko Haram think the secular school system has brainwashed Nigerians to accept the post-colonial Western order and forget the Islamic ways that existed before," said Jacob Zenn, an expert on the sect at the Washington-based Jamestown Foundation.
The attacks, which the U.N. children's fund (UNICEF) says have killed 48 students and seven teachers in the past month, aim to scare parents and their kids away from schools.
"It says: 'either take your children out of school or put them into an Islamist school we approve of'," Zenn said, one that teaches only in Arabic and omits courses like science.
He added that such schools need not necessarily be Boko Haram sponsored: there are conservative Islamic schools for children where they study under an Imam and the curriculum is all in Arabic and focused on the Koran. The sect accepts them.
Many people are turning away from education altogether.
"The risk isn't worth it. These guys are just mindless," said Mike Ojo, a mechanic in the northeastern city of Maiduguri who is taking his three children out of school.
Even if they stayed, many teachers have left, said teacher Ali Umar from a Maiduguri secondary school, and in many schools there are often too few teachers for the pupils who stay put, leaving them with little choice but to leave.
"I am not prepared to die for teaching. Time to start looking for a new job," he said, shrugging. "Most of our schools are deserted anyway."
The spot where Halima Musa's husband was shot dead at their home on June 16 -- in front of her and the children -- is still caked with his dried blood, the wall pocked with bullet holes.
They came at 3 a.m., guns blazing, demanding she open the door. She begged them to stop as they dragged the teacher out.
"They shot him three times in the head and told me that this should be a lesson not to marry a western educated person or any person that works for President Jonathan," she said, choking back tears in front of three traumatised children.
Yobe state education commissioner Mohammed Lamin complained that the military had not done enough to protect schools from attack, even after they were targeted.
Before the murderous assault on the Maumdo school, there had been an earlier attack on May 8, in which some property was burnt. Headmaster Haruna said the security forces he called for help patrolled initially but stopped after a week.
The military was not immediately available to comment, but it has said in the past it is doing all possible to protect civilians while crushing the insurgents in its offensive.
Schools are a devastating target for an impoverished region suffering a high rate of illiteracy, but Lamin says he is determined that Yobe's children get educated.
"These terrorists are trying to stop western education but we cannot allow them do that," he said. "We must do everything to ensure children are safe in the school."