Twenty-one of the schoolgirls kidnapped in 2014 by Boko Haram in Chibok, Nigeria, have been freed, the Nigerian government has confirmed.
Presidential spokesman Garba Shehu said the release was "the outcome of negotiations between the administration and Islamist militants".
A security official told the BBC several militants were freed in a swap - but the government later denied this.
Boko Haram seized more than 270 girls from a school in Chibok, north-east Nigeria, triggering global outcry.
More than 50 managed to escape the day they were captured, but it was believed more than 200 were still missing.
The kidnapping sparked one of the biggest global social media campaigns, with Twitter users employing the hashtag #BringBackOurGirls.
Mr Shehu said on Twitter that the International Committee of the Red Cross (ICRC) and the Swiss government had acted as mediators in the talks with Boko Haram.
Negotiations were continuing, Mr Shehu added.
The girls, who were due to arrive in the capital Abuja, would be examined by a team of doctors and psychologists, Information Minister Lai Mohammed said.
The government was confident that this "credible first step" would lead to the eventual release of the remaining girls, Mr Mohammed said.
However, he stressed that "this is not a swap".
"It is a release, the product of painstaking negotiations and trust on both sides," he said.
A security official has told the BBC that several top-level Boko Haram detainees were taken to a meeting point close to the Cameroon border.
Under the supervision of the ICRC, the girls were then released and the militants were handed over.
The students were then transported to the city of Maiduguri and placed under the supervision of the security forces.
According to the security official, most of the young women have babies.
Just last month the Nigerian government announced that several round of talks with Boko Haram had broken down, but with this release they have shown that those kidnapped can be released through intermediaries.
"I can only weep, right now. You know that kind of cry that is a mix of multiple emotions," Obiageli Ezekwesili, one of the leaders of the #BringBackOurGirls movement, tweeted in response to the news.
Only one previous release
Until now there had only been one confirmed release of a student kidnapped from Chibok.
In May, a 19-year-old woman was found by an army-backed vigilante group.
Boko Haram has kidnapped thousands of other people during its seven-year insurgency in north-east Nigeria.
More than 30,000 others have been killed, the government says, and hundreds of thousands have been forced to flee from their homes.
In the past days, the Nigerian military has been carrying out a large-scale offensive in the Sambisa forest, a stronghold of Boko Haram, which last year pledged loyalty to the Islamic State militant group.
Boko Haram controlled a swathe of land around the size of Belgium at the start of 2015, but Nigeria's army, aided by troops from neighbouring countries, has recaptured most of the territory.
The group still stages suicide bombings in the northeast, as well as in neighbouring Niger and Cameroon.
Boko Haram published a video in August apparently showing recent footage of dozens of the kidnapped girls and said some had been killed in air strikes.
The militant group has kidnapped hundreds of men, women and children but the kidnapping of the Chibok girls brought it worldwide attention.