The aid worker is free and safe, the German foreign ministry said Friday.
“Foreign minister (Frank-Walter) Steinmeier is relieved that a German man who was abducted in mid-April has been free since last night,” the spokeswoman told reporters.
“He is doing well under the circumstances and is in the custody of the German consulate in Mazar-i-Sharif” in northern Afghanistan, she added.
The German development agency GIZ, the man's employer, also confirmed he was free.
The spokeswoman declined to provide further details on the case, which was kept quiet during the hostage's captivity, but said a crisis team had worked to secure his release.
Steinmeier also discussed the case with Afghan President Ashraf Ghani in early May.
“The German government wishes to thank the Afghan government and the Afghan security forces for their full support in Kabul and Kunduz,” the spokeswoman said.
Asked whether a ransom had been paid, she reiterated the standard German position: “The government does not allow itself to be blackmailed.”
There has been an increase in kidnappings by militant groups in Afghanistan this year.
Earlier this month, Kabul was able to secure the release of 19 out of 31 mostly Shiite Afghans kidnapped by gunmen in the southern part of the country in early February in what was reported to be a prisoner swap.
Meanwhile, a German kidnapped last month is released from Taliban captivity in Kunduz. Here /w Chardhara police chief pic.twitter.com/cPQNDEHeto
— Subel (@svbel) May 29, 2015