An Indian dhow named the MV Nimatullah with 14 crew was released by the pirates, as was a vessel chartered by the UN's World Food Programme (WFP).
The MV Rozen vessel was carrying 1,800 tons of food to the beleagured capital of Somalia, Mogadishu, which has seen hundreds of its citizens killed in violence between government loyalists and Islamist insurgents.
Analysts say piracy levels fell dramatically under the brief six-month rule of the Union of Islamic Courts (UIC) which ended over the new year period when Ethiopian forces intervened to back Somalia's weak transitional government.
They fear that the capture of the Nimatullah and Rozen are symptomatic of a return to previous levels of insecurity on the high seas around the Horn of Africa area.
"WFP welcomes the release after 40 days of the MV Rozen and its 12-person crew on Thursday night and thanks elders in Puntland [the semi-autonomous region south of the Horn of Africa] for their mediation," Peter Goossens, the WFP's Somalia director, said.
"The threat of piracy however is still very much alive in Somali waters," he added, calling for the new Mogadishu government to "curb this menace".
Click here to run an energy price comparison, and see if you could be paying less for your gas and electricity.