Nigeria secured the release with mediation by the International Committee of the Red Cross. A military source said three Boko Haram commanders had been freed in an exchange, but declined to give further details.
The kidnapping was one of the high-profile incidents of Boko Haram's insurgency, now in its eighth year and with little sign of ending. About 220 were abducted from their school in a night-time attack.
The jihadi group has displaced more than 2 million people across northeast Nigeria and neighboring countries.
Arik Air stopped flying to Maiduguri, the birthplace of the jihadi group, in December 2013.
He is Nigeria's second-highest Islamic authority and he denies misusing state funds on Rolls Royces and mobile phone bills.
Buhari has missed several cabinet meetings and is still recovering following a months-long absence in the U.K.
Buhari returned in March from a two-month medical absence in the U.K.
Ahmed Abba spent two years in detention before he was convicted.
Despite help from the U.S., two successive Nigerian presidents have failed to liberate the vast majority of girls captured by Boko Haram.
Nigerian authorities say they have arrested five Boko Haram members.
The group's use of children has increased by 200 percent.
In Cameroon, hundreds of thousands of displaced people are at risk of starving after years of conflict with Islamist militants.
Nigeria has a patchy human rights record and has mistakenly bombed displaced civilians.
Billions of dollars were allegedly used for bribes in an unsuccessful bid to get ex-president Goodluck Jonathan re-elected.
The Nigerian military has said it killed Shekau on at least three occasions.
Monday a presidential adviser had urged Nigerians to reconsider their trip.
The 14-year-old girl said she was told to blow herself up in a city center.
The attackers blew themselves up outside a gas station, damaging fuel tankers.
Nigeria hopes world powers will supplement the government's efforts to fix the destruction Boko Haram left behind.
The militant group has displaced more than 2 million people in West Africa.
Seven suicide bombers blew themselves up near a refugee camp on Friday.
The protests went ahead despite a star singer dropping out.
The singer has called for a peaceful march against the country's economic crisis.