"His kidnappers gave a call to the UN headquarters in the afternoon telling staffers that they released Mr Keynan," the official said.
Several aid workers have been seized this year in the lawless nation by gunmen who often demand hefty ransoms.
The UNHCR said it would nonetheless continue to provide aid to displaced Somali civilians.
On Saturday two foreign journalists and their local fixer were abducted by armed men who are yet to make demands.
Abdullahi Yusuf Ahmed, Somalia's president, said on Tuesday all steps were being taken to free them.
Earlier this month, armed freed two Italian aid workers held for 10 weeks after being kidnapped near Mogadishu.
A German couple seized in June by pirates were also released unharmed.
Two demining experts from Sweden and Denmark were also freed in June hours after their capture.
Aid workers, including foreigners, have been repeatedly targeted in recent months by armed groups in Somalia, one of the world's most lawless states.
The spate of kidnappings and killings has hampered aid deliveries in the Horn of Africa country, which faces a humanitarian catastrophe.
There has been mounting unrest in the country since Ethiopian troops ousted an Islamist militia that had controlled large parts of Somalia in 2006.
Ethiopian forces rolled into Somalia, which has lacked an effective government since 1991, in late 2006 at the request of the embattled transitional administration.
Islamist fighters have since waged a deadly guerrilla war targeting Ethiopian and governemnt forces as well as African Union troops in Mogadishu.