The assailants stormed the Government Science secondary school in the Kagara district of Niger state at around 2 a.m., overwhelming the school's security detail, according to local residents.
One student was killed in the attack, teacher Aliyu Isa and a pupil at the school told local TV news station Channels. Another teacher, who did not want to be named, also told Reuters that one student was killed.
"It was only one that was killed," Isa told Channels. He said the abductors were dressed in army uniforms and shooting as they broke into the school. "They were telling the students not to run," added Isa, who said he and others fled in the confusion while the gunmen rounded up some of the pupils.
Niger state officials did not immediately confirm the death but said that 27 students, some members of staff and relatives had been abducted by the gunmen.
The attack came two months after gunmen stormed a secondary school in northwestern Katsina state and kidnapped nearly 350 boys, who were subsequently rescued by security forces.
It was not immediately clear who was responsible for the latest abduction. Kidnappings for ransom by armed groups are common across many northern Nigerian states.
Militant Islamist group Boko Haram and a branch of Islamic State also carry out abductions in Nigeria's turbulent northeast. About 100 of more than 270 schoolgirls abducted by Boko Haram from the town of Chibok in 2014 remain missing.
The Niger state governor ordered the immediate closure of boarding schools in the region. President Muhammadu Buhari dispatched security chiefs to coordinate rescue operations, his spokesman Garba Shehu said in a statement.
"President Buhari has (given assurance) of the support of his administration to the armed forces in their brave struggle against terrorism and banditry and urged them to do all that can be done to bring an end to this saga," said Shehu.
The spate of attacks has raised concern about rising violence by Islamist insurgents and armed gangs and fuelled widespread criticism of Buhari's handling of national security. In January, the president appointed a new military high command.
Violence and insecurity have compounded the economic challenges faced by citizens in Africa's most populous country, which is struggling to cope with a fall in revenues due to an oil price slump on top of the COVID-19 pandemic.