Gunmen free kidnapped schoolchildren in Nigeria
The BBC said, some 136 students from the school in Tegina, Niger state, were seized by gunmen demanding a ransom.
It added, the head teacher said a small number escaped in June. There were unconfirmed reports that six died in captivity.
Mass abductions for ransom have become increasingly common across Nigeria in recent months.
Head teacher Abubakar Alhassan said he could not give an exact number of how many students had been freed, but "none of the pupils are in captivity".
He told the BBC that the freed students were looking unhealthy, frail and exhausted. They are now being treated in hospital in the state capital, Minna.
Last month, the parents and the school had raised funds to free the pupils but the kidnappers told them that it was not enough.
Mr Alhassan said that they then paid more money and even bought motorcycles for those behind the mass abduction to convince them to release the children, the BBC's Ishaq Khalid reports from the capital, Abuja.
Read more: Boko Haram kills 16 soldiers in southeastern Niger
Fati Abdullahi, whose 18-year-old daughter and 15-year-old son were taken by the group, told the AFP news agency that her children had been freed.
"We are anxious to see them," she said.
On 30 May, gunmen riding on motorcycles stormed the town and opened fire, killing one person and injuring another.
As people fled, the attackers went to the school and seized the children.
In July, kidnappers seized a man who was sent to deliver a ransom payment to secure the students' release. Parents and school administrators had sold possessions and part of the school's land to pay the ransom. But they later said they wanted more money.
More than 1,000 students have been abducted from schools across northern Nigeria since December last year, although most have since been freed.
Authorities there have been criticised for their failure to tackle the country's widespread insecurity including the deepening kidnapping crisis.