Rüdiger Schwidt, who is in his 60s, reportedly has lung cancer. He was seized by tribesmen demanding the release of two relatives jailed by the Yemeni authorities, a foreign ministry official said.
He was freed after President Abdrabuh Mansur Hadi authorized the release of one of the two detainees, sources close to the mediators told AFP.
One of the mediators who saw the German after his release told AFP that Schwidt "appears tired and worn out but his overall health is good."
The hostage, who had been held in the eastern desert province of Marib, was handed over to interior ministry officials who were to deliver him to the German embassy in Sanaa, the mediator said.
In March, Schwidt appeared in a short video shown on a private television channel along with a kidnapper wielding a Kalashnikov rifle.
The state Saba news agency said that the German had been freed thanks to the mediation of Al-Jawf provincial governor Mohammed bin Abboud, who has tribal links with neighbouring Marib province.
Hundreds of foreigners have been kidnapped in Yemen over the past two decades by tribesmen who use them as bargaining chips in disputes with the government. Nearly all have been freed unharmed.
But in recent years, Al-Qaeda loyalists too have carried out kidnappings, prompting abduction targets to put up more resistance.
Last month, a German diplomat was wounded as he evaded a kidnap attempt in Sanaa. In October, a German embassy security guard was killed as he resisted abduction.
SEE ALSO: German embassy guard shot dead in Yemen