The girls were among 276 kidnapped in the northern town of Chibok in 2014 and this group is the largest to be freed.
They were exchanged for five Boko Haram commanders held by the authorities after "lengthy negotiations" involving Switzerland and the International Committee of the Red Cross, a Nigerian government official said.
A minister and father of two of the girls said: "I can confirm they have been released."
A military source said the girls were currently in Banki near the Cameroon border for medical checks before being airlifted to Maiduguri, the capital of Borno state.
They are expected to meet Nigeria's President Muhammadu Buhari on Sunday in the country's capital Abuja.
The kidnappings sparked a global campaign #bringbackourgirls supported by then US First Lady Michelle Obama.
Bukky Shonibare one of the founders of the campaign said: "This is exciting news for us, for the parents and the Chibok community. A very exciting and welcome development."