"They are now with us, and we are going to Hudur to hand over the MSF officers. They are free now. And this will not happen again," Yare said.
MSF confirms release
The pair were taken on April 19 after carrying out a nutrition study, while on their way to Hodur, a town near the Ethiopian border.
Their abductors had demanded a ransom.
A local MSF worker also confirmed their release.
A total of 35 aid workers were killed in Somalia in 2008 and 26 abducted, the UN says.
The attacks have limited the ability of relief agencies to respond to one of Africa's longest humanitarian crisis.
More than three million Somalis - nearly half the population - depend on emergency food aid in a country that has been without an effective central government since 1991.
The Bakol region, near the Ethiopian border, is under the control of an armed opposition group that is fighting Somalia's weak UN-backed government.