Colombia has withdrawn from a treaty that binds it to the U.N. International Court of Justice in anger at a ruling that shifts some of its resource-rich waters to Nicaragua, President Juan Manuel Santos said on Wednesday.

The Hague-based court last week reduced an expanse of sea belonging to Colombia, drawing a demarcation line in favor of Nicaragua even while saying a cluster of disputed islands in the western Caribbean belonged to Colombia and not to Managua.

The decision set off a scramble in Bogota to see how to overturn the verdict and avoid diplomatic conflict with Nicaragua's President Daniel Ortega, who sent ships to the area.

Santos has ordered the Colombian navy to remain in the waters granted to Managua.

"The highest national interests demand that territorial and maritime limits are set by agreements as has always been the case in Colombian judicial tradition, and not via rulings uttered by the International Court of Justice," Santos said.

"This is the moment for national unity. This is the moment that the country has to unite."

The 1948 treaty, known as the Bogota Pact, recognizes ICJ rulings to find peaceful solutions to signatories' conflicts.

Leaving the pact would mean Colombia is not obliged to heed the court's ruling on any potential bids by Nicaragua to seek additional territory, the government has said.

But its withdrawal would not have a retroactive effect, and it would be obliged to comply with last week's ruling.

Ortega has said he expects Colombia to recognize the court decision, which is binding, but experts have said Colombia may reject it and seek to negotiate a new border pact.

The Hague's ruling set off alarms farther afield as the court will hear arguments next week on a maritime dispute between Chile and Peru, which could potentially award a swathe of Pacific Ocean under Chilean sovereignty to its northern neighbor.

"Chile has been, and always will be, a country that fully respects international law," Foreign Minister Alfredo Moreno said on Wednesday in the northern Chilean city of Arica, which was Peruvian until the 19th century.

In Colombia, Santos has not yet said whether he will accept the latest ICJ decision, which Nicaragua presented to the Hague in 2001. He expressed anger at the changes, saying the ruling had "omissions, mistakes, excesses, inconsistencies."

Santos highlighted other countries that have taken similar decisions, including Norway, Canada, Australia and New Zealand.

Nicaragua's continental shelf and economic exclusion zone in the Caribbean was increased by the court ruling, giving it access to potential underwater oil and gas deposits as well as fishing rights.

In 2007, the court ruled in the long-running dispute between the two countries that three large islands of San Andres, Providencia and Santa Catalina belonged to Colombia.

"The ICJ is not a biased court and it followed established principles," said William Schabas, professor of law at Middlesex University in the United Kingdom.

"In the long run the ICJ only benefits Colombia, and it's a shame they throw what amounts to an international law temper-tantrum like this," he said.