Published On : Friday, October 14 2016
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
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 man seals mouth with a branded sticker reading 'Bring Back Our Girls Now'Image copyrightAFP
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".
The kidnap of the Chibok girls sparked a global campaign
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.