The US navy said a ransom appeared to have been dispatched on Wednesday and Mikhail Voitenko, said to be a spokesman for ship owner Vadim Alperin, later said that the pirates were "counting the haul".
Early on Thursday groups of pirates began leaving the vessel, reports from Harardhere said. Representatives of the pirates then told journalists that the ship had been freed.
"We have released MV Faina. There were only three boys remaining and they delayed the release for one hour, but now the ship is free," one of the pirate leaders, Sugule Ali, told AFP news agency by phone.
"No huge amount has been paid, but something to cover our expenses," he added.
Victor Shapovalov, the father of a senior officer on the ship, told the BBC Ukrainian Section that relatives did not have direct communication with the ship.
"We have direct contacts with other people," he said. "[The crew] are alive, but whether they are in a good health, that is a big question."
"I think that the negotiations lasted very long time - four months. But of course I am very happy with the result," he said.
Cargo of weapons
The Russian captain of the ship died shortly after the seizure - apparently of a heart attack.
File footage of the Ukrainian ship off the coast of Somalia
The rest of the crew - 17 Ukrainians, two Russians and a Latvian - were healthy and safe, a statement from the Ukrainian presidency said, and the ship would head to Mombasa under the protection of the US navy.
A number of warships from foreign navies had been diverted to the area to monitor the situation, in part to ensure that the cargo of weaponry did not get into the hands of Somali insurgents.
Once the ship is under way, the focus is likely to shift to its cargo of weapons and its final destination, says the BBC's Peter Greste in the Kenyan capital, Nairobi.
The Kenyan government would be highly embarrassed to be found supplying arms to South Sudan, analysts say.
It was Kenya that helped broker an end to the civil war between South Sudan and the government in Khartoum in 2005.
Somali waters are among the most dangerous for pirate activities in the world.
Last year pirates in the area collected an estimated total of $50m (£35m) in ransom. But a recent BBC investigation has found that it costs as much again to negotiate and deliver these ransoms.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.