Journalist Michael Scott Moore, who has dual US and German citizenship, has been released after nearly three years in captivity in Somalia, officials say.
Ahmed Muse Noor, deputy commissioner of the Mudug region, said Mr Scott had been taken by armed militia to an airport in the town of Galkayo.
German newspaper Der Spiegel reported that the 45-year-old had been taken by plane to the Somali capital, Mogadishu.
He was kidnapped in January 2012 while researching a book on piracy.
Somali pirates have been active in this area but it is not clear which armed group kidnapped Mr Scott.
The German paper quoted officials who said the journalist, who freelanced for the paper, was in good condition and overjoyed at his release.
Editor-in-chief Wolfgang Buchner said: "We never gave up hope and are now rejoicing with Michael and his family that this nightmare has finally come to an end."
And a statement from the foreign ministry said a "German citizen who also had US citizenship who was kidnapped in Somalia was set free today".
Various armed groups have been battling for control of Somalia since the overthrow of President Siad Barre in 1991.
Many southern and central areas are now controlled by al-Shabab, which is fighting the UN-backed government, but the Islamist militant group is not thought to be linked to Mr Scott's captivity.