Taleban militants have freed one German and four Afghans held hostage in Afghanistan since July in exchange for the release of several Taleban prisoners.

Jaghato district chief Mohammed Nahim in Wardak province says the hostage swap took place earlier Wednesday. The official and the private Afghan news agency, Pajhwok, says the freed Taleban militants were related to the kidnappers.

The German, Rudolf Blechschmidt, was captured in Wardak province along with the Afghans and another German, who became ill while in captivity and was shot dead.

German Foreign Minister Frank-Walter Steinmeier confirmed the release of the engineer, saying officials were happy and relieved.

Blechschmidt appeared in a video in August pleading for his freedom and saying his health was deteriorating. Taleban kidnappers demanded Germany withdraw its troops serving with the NATO mission in Afghanistan. The German government refused.

Some information for this report was provided by AFP, AP and Reuters.