"They got their freedom back after having been in captivity for a long time. The local elders and Puntland authorities helped their release," said district commissioner Yusuf Jama.
"They are now in Bossaso and will be soon flown to their country," he said, referring to the de facto capital of the Puntland region and Somalia's main port.
Pirates routinely kidnap foreigners off the coast of Puntland and demand huge ransoms that are often secured with regional officials acting as go-betweens.
One of the elders involved in the release of the Germans, Mohamed Cheick Hassan, said a deal had been struck with the kidnappers late on Friday.
The pirates had reportedly demanded millions of euros for the pair but Hassan made no mention of any ransom being paid.
"We succeeded (in gaining) the release of the German hostages late last night after discussing with the kidnappers... they are now free," he said.
Shortly after the Germans were kidnapped, the German foreign ministry said they had been taken ashore by their abductors.
The pirates allowed the couple, identified only as Jurgen K., and Sabine M., to telephone relatives at the beginning of July, according to the German weekly news magazine Der Spiegel.
They told family members they were well given the circumstances, the report said.
The German foreign ministry had also sent a package of medication via intermediaries for the man, who is a diabetic.
Nothing had been heard of them for several weeks since.