Pirates released the German vessel Hansa Stavanger and its 24-strong crew after being paid 2.7 million dollars. It was later escorted from the Somali coast by a European Union naval force, said Andrew Mwangura of the Kenya-based East African Seafarers' Assistance Programme.
"She is heading up north," he told AFP without specifying its destination.
The 20,000-tonne vessel was seized in April around 400 nautical miles from the Somali coast, between Kenya and the Seychelles.
In Berlin, German Foreign Minister Frank-Walter Steinmeier confirmed the release.
"I have learned with great relief that the crew of the Hansa Stavanger has been freed," Steinmeier said in a statement, which added that the crew members were well.
Earlier, hijackers freed a Malaysian tugboat with 11 sailors, ending the second longest hostage saga off the coast of Somalia, a maritime watchdog said.
The TB Masindra 7 and its attached Indonesian barge ADM1 had been operating under a contract from French oil giant Total when it was seized eight months ago on December 16, said Kenya-based Ecoterra International.
The tugboat crew was "all right, given the circumstances," said the statement adding that "a ransom was paid."
The tugboat and barge had been on their way back to Malaysia from Mukallah in Yemen when the vessels were boarded by pirates.
Mwangura said the crew were "safe and sound" after their ordeal and their ship was "now steaming out to safe waters."
He gave no details of the amount of the ransom.
The boat had been moved between pirate hideouts but lately had been held off Hobyo village in northern Somalia, Mwangura explained.
Small villages dotting the coast of Somalia's self-declared state of Puntland are the pirates' main bases.
Ecoterra said a lack of cooperation between the Malaysian and Indonesian ship owners meant the case dragged on for months.
Over long stretches the crew felt completely abandoned. One engine of the tugboat was damaged during the first night of the sea-jacking and provisionally repaired. Vessel, barge and crew therefore are approaching the nearest harbour for repairs and bunker," it said.
The eight-month hostage saga is the second longest ship seizure by the Somali criminal gangs. A Nigerian tugboat and its 11 crew were held for 10 months before their release in June.
Some 200 sailors and at least 11 ships are still being held in the region.
Somali pirates attacked more than 130 merchant ships last year, a rise of more than 200 percent over 2007, according to the International Maritime Bureau.
Rough seas and international navy patrols have curbed pirate attacks in the Gulf of Aden and Indian Ocean in recent weeks, but experts have warned that the end of the monsoon season could see a fresh flurry of hijackings over the next few weeks.
More than 30 ships from 16 nations, including NATO members and the European Union, are patrolling the waters off the Somali coast to try to ensure safe passage for ships heading to and from the Suez Canal.
Last month, a Turkish frigate operating with NATO forces intercepted a skiff in the Gulf of Aden and captured five pirates after a tip-off that they were preparing attacks, the Turkish general staff said in Ankara.
Gangs armed with rifles, rocket-launchers and grappling hooks attack their prey by launching small and nimble skiffs from larger ships, generally small cargo boats or fishing vessels they have previously hijacked.
Their most spectacular catch was the Saudi-owned supertanker Sirius Star captured late last year with its cargo of two million barrels of crude oil and freed after two months.
Meanwhile, two crew members from a Turkish cargo ship suffered bullet wounds when their vessel was attacked off Nigeria early Monday, Turkish media reported.
The Duden, which was transporting a cargo of rice, was attacked off Port Harcourt, the Anatolia news agency said. The cook and a steward suffered minor wounds to their arms.