Six armed men stormed the MV Miltzow freighter on Wednesday as its cargo of 850 tons of food aid was being offloaded in the port of Merka, and forced it to sail down the coast to Barawa.
The hijacking came 10 days after pirates released another ship laden with UN World Food Programme (WFP) aid, the MV Semlow, which they seized at sea and held for nearly 100 days.
But quick negotiations by the contractor hired by WFP to deliver the food and an official from Barawa, 160km southwest of the capital Mogadishu, secured the release of the Miltzow, its cargo and crew of one Ugandan and seven Kenyans.
"The ship has been released and they started negotiating yesterday," WFP spokeswoman Anja du Toit said on Friday.
"The only thing we know is that the hijackers demanded a ransom of $20,000, but we don't know if that has been paid," du Toit added.
She said WFP did not and would not pay the ransom.
The Indian Ocean waters off Somalia are among the most dangerous in the world. The Horn of Africa nation of 10 million has had no proper government and no one to patrol its seas since 1991.
"The only thing we know is that the hijackers demanded a ransom of $20,000, but we don't know if that has been paid"
Anja du Toit,
Pirates in armed speedboats typically race alongside slower-moving ships, fire on them, then board and take control at gunpoint.
Reacting to the recent spate of attacks on ships, Somalia's interim government condemned "the culture of piracy by freelance militias who are plundering the Somali coastline".
After its release, the Miltzow sailed back to Merka to unload 400 tons of rice, maize and vegetable oil still left on board. It was sent to help 78,000 people suffering from hunger and violence in the nearby Jilib district.
"Everybody is fine and she is back in Merka," said Inayet Kudrati, director of the Motaku Shipping Agency based in Mombasa, Kenya.
"[Piracy] is a serious and dangerous new phenomena that is unfolding on the high seas of Somalia..."
Three ships owned by Motaku, including the two carrying UN food aid, have been hijacked in the last three months. One, seized with its crew of nine Kenyans and one Sri Lankan over the weekend, is still being held by pirates, he said.
The risk has prompted the shippers to stop sailing Somali routes until security is established.
The Somali government, struggling to establish authority at home, pleaded for international help watching its coast and financing and training its own coast guard.
"[Piracy] is a serious and dangerous new phenomena that is unfolding on the high seas of Somalia and is in fact a threat to all maritime vessels from the Red Sea to the southern tip of the Indian Ocean," it said.