The International Court of Justice ruled Monday that a group of tiny islands in the western Caribbean belongs to Colombia, but also granted Nicaragua control of a large swath of the surrounding sea and seabed that could hold oil reserves.
Based on evidence presented by lawyers for both nations, "Colombia and not Nicaragua has sovereignty over the islands," the court's President Peter Tomka told delegations from both sides.
But the decision not to grant Colombia full sovereignty over the waters connecting all the archipelago's islands drew a vehement objection from Colombia.
President Juan Manuel Santos told Colombians in a national speech that the court had "committed grave errors" by ignoring the terms of the very treaty it had declared valid and that the decision would hurt the archipelago's fishermen.
The decision effectively cut off four small islands from the rest of the archipelago and Santos said he could not accept the court's "omissions, errors, excesses and inconsistencies."
While Santos said he recognized that the court's decision is final and legally binding, he said Colombia "emphatically rejects this aspect of the decision" and "we don't rule out any recourse or mechanism that international law gives us to defend our rights."
He said he would fly to San Andres immediately.
Nicaragua hailed the ruling as an historic triumph.
President Daniel Ortega called it a "day of national victory, victory for all Nicaraguans," and called on Santos to respect the court's ruling.
Nicaragua's representative at the court, Carlos Arguello, said the ruling gives the poor Central American country "incredible potential wealth and future exploitation of fisheries and other resources, such as minerals."
"We've been given very important maritime territory," he said.
Undersea oil exploration concessions for the waters surrounding the islands were approved in 2010 by the Colombian government of then-President Alvaro Uribe.
After taking office later that year, Santos introduced legislation to begin the exploration but, after complaints from environmentalists and local politicians, reversed himself and said he would not allow the exploratory drilling.
The archipelago is home to one of the largest barrier reefs in the Americas, the 100-square-mile (255-square-kilometer) old Providence reef. The rich marine habitat was declared a UNESCO Biosphere Reserve in 2000.
Nicaragua first went to the world court, the United Nations' highest judicial organ, in 2001 arguing that Colombia had no legal claim to the islands.
The two countries' dispute over the region began in the late 1960s when Nicaragua granted oil exploration concessions for part of the seabed, but so far no drilling has started.
The court partially rejected that argument in 2007, saying a 1928 treaty between the two countries established that Colombia owned the English-speaking islands of San Andres, Providencia and Santa Catalina.
Those volcanic islands, 720 kilometers (450 miles) from Colombia's coast and 110 kilometers (70 miles) from Nicaragua's mainland, are popular among tourists for their pristine white beaches and coral reefs.
In Monday's ruling, the court's 15 judges said that several other smaller islands and cays in the region also belong to Colombia and set the maritime borders based on Colombia's ownership of the islands.
The new borders give Colombia control of the waters and seabed immediately surrounding its islands and cays but also give Nicaragua a large horseshoe-shaped area of the sea and seabed stretching from its mainland coast around the Colombian islands.
The provincial governor of San Andres, Auri Guerrero, told The Associated Press it was important that the court ruled that the waters immediately surrounding two outlying keys, Quitasueno and Serrana, are Colombian territory as they are extremely important for many of the 1,200 small fishermen who live in the archipelago.
But "a boundary has been set where we end up losing territorial water in San Andres province. In the end, we can't be happy or satisfied with the ruling." Two other keys, Serranilla and Bajo Nuevo, were similarly separated.
There are also two commercial fishing companies in the islands, which have 72,000 inhabitants, said Guerrero.
The islands were first settled by Puritans in the early 17th century, and later used as an outpost by pirates. Many inhabitants today are descendants of slaves who speak English as their first language.
Nicaragua had argued that when it ceded the archipelago to Colombia in a 1928 treaty, it did so under duress because Nicaragua was then occupied by U.S. Marines who were battling a leftist insurrection.
The territorial dispute prompted the Colombian military to step up its presence near the archipelago. Nicaragua's government accused Colombia's navy of intercepting and capturing Nicaraguan fishing boats off the Nicaraguan coast.
Luis Manuel Galeano in Managua, Nicaragua, Vivian Sequera and Cesar Garcia in Bogota, Colombia, and Frank Bajak in Lima, Peru, contributed to this report.