"We have released the ship and its crew overnight after receiving a ransom. It is free now and gone," Mohamed Abdi, a pirate in the Somalian coastal town Eyl told news agency AFP by telephone.
A spokesman for the EU's special nautical operation Atalanta confirmed that the cargo ship Victoria had been released and had already sailed away from the area. There were no German nationals among the crew.
The ship, which sailed for a German company under the flag of Antigua and Barbuda, had been hijacked at the beginning of May and taken to Eyl.
Elders in the town confirmed the ship had been released but could not confirm the ransom. "The German ship was released overnight by the pirates and it moved but I don't know what has been paid to the pirates," Abdulahi Garaad Mohamed, an elder in Eyl said.
Somali hijackers attacked more than 130 merchant ships off Somalia last year, a rise of more than 200 percent on 2007, according to the Kuala Lumpur-based International Maritime Bureau's Piracy Reporting Centre.
The world's naval powers have deployed dozens of warships to the lawless waters off Somalia over the past year in a bid to curb attacks on one of the world's busiest maritime trade routes.
The release comes a day after Defence Minister Franz Josef Jung dismissed the call from German ship operators to station soldiers on cargo vessels sailing along the hazardous Gulf of Aden.