A ship carrying food aid is being towed to the Somali port of El-Maan after being released by pirates, the UN says.
The Semlow was taking aid for victims of the tsunami
The MV Semlow ran out of fuel and is being towed by another ship carrying an Egyptian cargo which was also seized.
The UN is concerned that some of the grain on board, intended for Somali victims of the Indian Ocean tsunami, could be sold off once it docks.
It believes the owners of the Semlow, which was hijacked in June, have done a deal to get the pirates off their ship.
The World Food Programme has put adverts in the Somali press warning that dealing in stolen grain would be against international law.
More than a week ago, the MV Semlow sailed to El-Maan after an agreement had been reached.
But as the port authorities prepared to unload the cargo of 850 tons of rice, the pirates made new demands.
They then sailed away again, and used it to board the second boat, the Ibnu Batuta, which was carrying cement from Egypt.
The pirates had initially demanded $500,000 in ransom, but the WFP says no money was paid.
The crew comprises eight Kenyans, a Tanzanian and their Sri Lankan captain.
The ship was captured off Haradere, north of Mogadishu, after sailing from Mombasa in Kenya.
Somalia has had no functioning national government since 1991 and the country has been divided into fiefdoms run by rival warlords.
The International Maritime Board has warned of an alarming increase in piracy in Somali waters and has urged ships to avoid the area.
Last month, three smaller fishing vessels were hijacked by gunman off the southern port town of Kismayo and some 40 crew members are being held hostage.