The Maran Centaurus, one of the largest oil tankers ever seized, was captured on 29 November with 28 crew members.
A ransom of between $5.5m (£3.4m) and $7m (£4.3m) was dropped on the deck of the supertanker.
The money was said to have sparked an argument among the pirates and delayed the release of the ship.
"She’s free. She’s preparing to sail out" from Harardhere, Andrew Mwangura, of the East African Seafarers Assistance Programme, told the AFP news agency.
One pirate said the argument about the ransom money had been resolved.
"We have agreed to solve our disagreements and release the ship. It is free and sailing away now," one of the pirates, Hassan, told Reuters news agency by telephone.
"The crew are all safe."
Source: BBC