The UN's highest court says it cannot rule on Nicaraguan claims to three small Caribbean islands as a treaty giving them to Colombia is still valid.
Nicaragua had asked the International Court of Justice (ICJ) to grant it sovereignty over the islands, the focus of a lengthy dispute with Colombia.
But the ICJ said a 1928 treaty signed by both nations had settled the issue.
The ICJ said it could rule on their maritime border and claims over other islets in the rich fishing waters.
In its ruling on Thursday, the ICJ said that Colombian sovereignty over the San Andres, Providencia and Santa Catalina islands had been legitimately settled in a 1928 treaty signed by both countries.
The court said it therefore could have no jurisdiction over the issue.
The ICJ said it did have jurisdiction to rule on other islets and rocks in the archipelago and the maritime border in the area.
Both Colombia and Nicaragua were quick to react to the court's decisions.
Colombian Foreign Minister Fernando Araujo welcomed the fact that the ICJ had confirmed his nation's sovereignty over the islands.
"The court acknowledged that Nicaragua was trying to win recognition of rights over a part of Colombian territory in which it has never exercised sovereignty or legal authority," Mr Araujo told reporters in the Colombian capital, Bogota.
He said that his country would continue to exercise sovereignty over the rest of the disputed territory, which covers 50,000 sq km (19,310 sq miles).
Samuel Santos, the Nicaraguan foreign minister, said the ruling was a "step forward" and that the possible review of the maritime border could allow his country to expand its borders.
The issue has caused friction between the two nations since the 1980s when the Sandinista government in Nicaragua unilaterally annulled the 1928 agreement, arguing that it had been signed under US pressure.
The ICJ is now expected to seek new submissions from Colombia and Nicaragua, although it could be months before the case comes before the court.
The ICJ's rulings are binding.