Dozens of students were grabbed from a Nigerian college in March, sparking outcry. The last of them have now been freed.
Some 29 students have been freed by gunmen after being kidnapped, Nigerian authorities said on Wednesday.
In March, militants seized 39 students from the College of Forestry Mechanization in Kaduna state.
Security forces recovered 10 of them in the weeks following the attack, but the remaining students were still missing until Wednesday.
The kidnappers released a graphic ransom video, with captured female students yelling at their kidnappers while being struck. Other students pleaded for help from the government.
The head of the parents' association told Reuters news agency that the students were now with police and headed back to Kaduna city.
Ransom-seeking armed groups have increasingly kidnapped students from schools in northwest Nigeria.
Kaduna Governor Nasir El-Rufai said in that past that his state government will not negotiate with "bandits" or pay ransoms. In this case however, the parents group said a ransom had been paid, but would not say how much or to whom.
The Kaduna state commissioner for internal security said the government rejoiced with the freed students, and asked them to "put the past behind and work hard towards a happier and successful future ahead."
Nigeria has often struggled to tackle its security challenges against armed groups in recent years.
(Reuters, AFP, dpa)