Somali pirates holding an Algerian bulk carrier since 1 January, 2011 freed the ship and the 25 crewmen being held hostage on Thursday, the foreign ministry said.
"It is with great joy and profound relief that we announce the release this morning of the 25 crew of the MV Blida," ministry spokesman Amar Belani said in a statement sent to AFP.
The Blida was captured on its way from Salalah in Oman to Dar el-Salaam in Tanzania with a crew of 17 Algerians, six Ukrainians including the captain, two Filipinos, an Indonesian and a Jordanian.
Belani said on October 12 that an Algerian and a Ukrainian had been released on humanitarian grounds, adding, "Negotiations are very difficult but are making progress."
Given the news by AFP, the son of one of the hostages, engineer Mohamed Ait Ramdane, 55, broke into sobs.
"Thank God, it is fantastic," Fawzi Ait Ramdane said.
Relatives of the Algerian hostages organised regular protests to demand more effective government action to secure the crew's release.
Belani said the vessel was heading for the Kenyan port of Mombasa under the protection of international naval forces operating in the region to counter widespread piracy.
He said the health of the hostages caused no concern and they should be repatriated soon.
"Algeria welcomes this happy outcome which brings an end to a long and trying captivity and will spare no effort to ensure the authors of this act of piracy are prosecuted and tried by competent authorities," Belani added.
He said Algiers had paid no ransom in line with its official policy.
According to Ecoterra International, an environmental and human rights NGO monitoring maritime activity in the region, Somali pirates still hold at least 46 vessels and some 500 seamen.
The last one to be seized was a Greek chemical tanker with 22 sailors aboard which was hijacked on Monday.