The German-American journalist Michael Scott Moore has been freed in Somalia, nearly three years after he was abducted by an armed militia while researching a book about piracy.

Moore, 45, who has dual citizenship, was flown to the capital Mogadishu on Tuesday and appeared to be in good health, according to Spiegel Online, the German publication for which he was working as a freelancer at the time of his kidnapping. Security officials cited by Spiegel said he was overjoyed that his ordeal was now over.

Authorities in Somalia and Germany confirmed that he had been freed. "The Western journalist was released," Abdi Yusuf, the interior minister of the semi-autonomous central region of Galmudug, where Moore was kidnapped, told Reuters. He said that to the best of his knowledge no ransom had been paid.

The journalist was reportedly brought by the militia to an airport in the city of Galkayo, after which he was transferred to the Somali capital on a small plane. "A German citizen who also had US citizenship who was kidnapped in Somalia was set free today," the German foreign ministry confirmed.

Moore was abducted by an armed group in Galkayo in January 2012. Somali pirates — the subject of his research — are active in the area, though the identity of his kidnappers has never been confirmed.

Spiegel said that the German foreign ministry's crisis team worked closely with US officials to secure the release of the journalist, in efforts involving a series of negotiators. Occasional proof-of-life photos were released by Moore's abductors as his captivity stretched on.

Wolfgang Büchner, Speigel's editor-in-chief, expressed gratitude to everyone who had worked for his release. "We never gave up hope and are now rejoicing with Michael and his family that this nightmare has finally come to an end," Büchner said in Hamburg.

"We're grateful to all the people who have worked so long to bring about Michael's release — and thrilled that he and his family can be reunited at last," said Jon Sawyer, executive director of the Pulitzer Center on Crisis Reporting, which had provided Moore with a grant for his work ahead of his kidnap.

Mired in a decades-long conflict involving multiple armed groups, Somalia has lost swaths of its central and southern territory to the Islamist group al Shabaab, which is fighting both the government in Mogadishu and its allies in neighboring Kenya. However the al Qaeda-linked organization is not thought to have been involved in Moore's abduction.