Girls among the nearly 300 who were kidnapped from a school in north-western Nigeria have been describing their ordeal following their release.
"Most of us got injured," one of the schoolgirls told the BBC, adding that gunmen threatened to shoot them.
The girls were abducted by unidentified assailants from their boarding school in Jangebe, Zamfara state, on Friday and taken to a forest, police said.
The state's governor said on Tuesday that the 279 girls had been freed.
Such kidnappings are carried out for ransom and are common in the north of the country.
On Tuesday, dozens of the girls were seen gathered at a government building in Zamfara after they were taken there in a fleet of mini-buses.
Speaking to the BBC, one of the schoolgirls said that some of those kidnapped had found it difficult to continue walking when instructed to do so by the gunmen because of their injuries.
"They said they [would] shoot anybody who did not continue to walk," she said. "We walked across a river and they hid us and let us sleep under shrubs in a forest."
Another of the girls, aged 15, said that some of her classmates found it difficult "walking in the stones and thorns" and had to be carried.
"They started hitting us with guns so that we [would] move," she told Reuters news agency, adding: "While they were beating them with guns, some of them were crying and moving at the same time."
Some of the fathers who had arrived to see their daughters for the first time since their abduction told reporters they were "very happy" at the news of their release.
The group's release was secured through negotiations between government officials and the abductors, authorities in Zamfara state told the BBC.
Local authorities said that an earlier figure provided by police of 317 for the number of girls kidnapped was not accurate.
One official told Reuters that the discrepancy was because of the fact that some girls had fled shortly after being abducted.
Nigeria's President Muhammadu Buhari said he felt "overwhelming joy" at the news of the girls' release. "[I am] pleased that their ordeal has come to a happy end without any incident," he said.
The governor of Zamfara state, Bello Matawalle, tweeted that it "gladdens my heart to announce the release of the abducted students".
"This follows the scaling of several hurdles laid against our efforts," he added. "I enjoin all well-meaning Nigerians to rejoice with us as our daughters are now safe."
Mr Matawalle has denied paying for the girls to be released, but last week President Buhari admitted state governments had paid kidnappers "with money and vehicles" in the past and urged them to review the policy.
Analysis: Nigeria's ransom controversy
By Ishaq Khalid, BBC News, Abuja
It is believed that schools have started to be targeted as such abductions attract a lot of attention - putting more pressure on the authorities to negotiate with the armed criminal group responsible.
The authorities rarely admit to paying ransoms - but some observers say it is unlikely that the gunmen would release their victims without some sort of exchange, either of money or the release of their members who are in jail.
Besides, kidnapping for ransom is a widespread criminal enterprise across the country - people are seized by gunmen on almost a daily basis - with both the rich and the poor falling victims. Security personnel have been held too. People often speak of how they have managed to secure someone's release by raising funds from friends and relatives - or even selling their assets.
But ransom payments are controversial. It may save someone's life, yet some observers say paying ransom only fuels the problem. President Buhari agrees, saying today ''ransom payments will continue to prosper kidnapping''.
He has repeatedly said his government will not negotiate with the armed criminal gangs. But many believe the failure of his administration and those at the state level to provide security is to blame. There are growing calls for the authorities to provide security for thousands of schools across the country - many of which are unfenced and do not have adequate security guards.
The 2014 kidnap of 276 schoolgirls in the north-eastern town of Chibok by Islamist militants Boko Haram brought global attention to the scourge of raids on schools in Nigeria, but a surge in recent attacks is suspected to be the work of criminal gangs.
The raid in Zamfara state was the region's second kidnapping in recent weeks. Some 27 students were kidnapped from a boarding school in Kagara in the north-central state of Niger last month before they were released on 17 February.
No group has said they were behind the Zamfara kidnappings.
Armed groups operating in the state often kidnap for ransom but when gunmen took more than 300 boys from Kankara in neighbouring Katsina state in December last year, some reports said Boko Haram, which operates hundreds of miles away in the north-east, was behind the attack.
The reports were later disputed and the boys released after negotiations.