Eye witnesses said some of the victims were burned alive in the attack, in Mamudo town, Yobe state.
Dozens of schools have been burned in attacks by Islamists since 2010.
Yobe is one of three states where President Goodluck Jonathan declared a state of emergency in May, sending thousands of troops to the area.
A reporter from the Associated Press found chaotic scenes at the hospital in nearby Potiskum, where traumatised parents struggled to identify their children among the charred bodies and gunshot victims.
Survivors said suspected militants arrived with containers full of fuel and set fire to the school.
Some pupils were burned alive, others were shot as they tried to flee.
More than 600 people were believed to have been killed in 2012 by the group, which is fighting to overthrow the government and create an Islamic state in Nigeria’s predominantly Muslim north.