Twenty-one of the schoolgirls kidnapped in 2014 by Boko Haram in Chibok, Nigeria, have been freed, the president's spokesman has confirmed.
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.
It sparked one of the biggest global social media campaigns, with tweeters using the hashtag #BringBackOurGirls.
President Muhammadu Buhari's spokesman 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.
Mr Shehu added that negotiations were continuing.
The girls, who are due to arrive in Abuja, would be examined by a team of doctors and psychologists, Information Minister Lai Mohammed told journalists in the capital Abuja.
Mr Mohammed said the government was confident that this "credible first step" would lead to the eventual release of the remaining girls.
However, he stressed that "this is not a swap".
"It is a release, the product of painstaking negotiations and trust on both sides," the minister said.
How the schoolgirls were freed - Martin Patience, BBC Nigeria reporter
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, has tweeted in response to the news.
The president also tweeted that he welcomed the release "following successful negotiations".
Up to 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.
After that it was believed that 218 students were still missing. More than 50 managed to escape on the day they were captured.
Boko Haram has also 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.
Boko Haram at a glance:
- Founded in 2002, initially focused on opposing Western-style education - Boko Haram means "Western education is forbidden" in the Hausa language
- Launched military operations in 2009
- Thousands killed, mostly in north-eastern Nigeria, hundreds abducted, including at least 200 schoolgirls
- Seized large area in north-east Nigeria, where it declared caliphate
- Joined so-called Islamic State, now calls itself IS's "West African province"
- Regional force has now retaken most of the captured territory
- Group split in August after rival leaders emerged