The UN demanded the immediate release at the weekend of the Argentine navy training ship ARA Libertad impounded by Ghana two months ago at the request of a "vulture" hedge fund owned by the US billionaire Paul Stringer.
Hernan Lorenzino, the Argentine economy minister, hailed the decision and vowed to continue fighting what Cristina Fernandez, the president, has called "vulture funds", with which the country is locked in a series of legal battles.
"Argentina will continue to defend itself from the financial pirates," Mr Lorenzino said via Twitter. "Vultures, you won't succeed, with the ship nor with the debt."
The tall ship was detained on October 2 in the port of Tema as collateral for unpaid bonds dating from Argentina's economic crisis of 2002. Argentina appealed to the UN's international tribunal for the law of the sea for the ship's release, arguing that as a warship the Libertad is immune from being seized.
There was no comment from judicial authorities in Ghana about the ruling.
In an expedited ruling, the court ordered that Ghana "forthwith and unconditionally release the frigate ARA Libertad" and ensure the ship and its crew can leave Ghanaian waters. It also ordered that the vessel be resupplied as needed.
Detaining the ship was "a source of conflict that may endanger friendly relations among states", the court said. The ruling left untouched the parties' rights to seek further international arbitration on the matter.
Ghana courts ordered the ship held on a claim by the hedge fund NML Capital, based in the Caymen Islands. Mr Singer, the company's owner, is demanding payment in full of $1.6bn, plus interest - about $350 million - for dollar-based Argentine bonds bought at fire sale prices after Argentina's 2001-2002 economic collapse. Mr Singer, who owns debt from the country's $95bn default, has rejected two restructuring offers that paid investors about 30 cents on the dollar.
The vast majority of bondholders accepted the deal on the dollar years ago and that is about what the hold-outs led by Singer initially paid for the bonds.
NML criticised the tribunal for making a ruling.
"The Ghanaian courts have sole jurisdiction over this dispute, and that is where this matter has been and will continue to be lawfully heard," it said.
"It is completely inappropriate for the international tribunal for the law of the sea to attempt to interfere with orderly proceedings of the independent judiciary of Ghana."
Susana Ruiz Cerutti, the head of Argentina's delegation to the tribunal, was quoted by the Telam state news agency as praising the ruling for being unanimous and for siding with the vessel's captain, who had been accused of contempt.
It was not immediately clear how soon, or if, the ship would be allowed to set sail.
Richard Anamoo, the director-general of the Ghana ports and harbours authority, said it was "not the port authorities that are holding the ship. We were only implementing a [Ghanaian] court order."
* with AP