Costa Rica has taken Nicaragua to the top UN court, accusing it of a breach of territorial integrity over a disputed river border and warning of "extreme hostility and tension".

Costa Rica accused Nicaragua of deploying troops inside its territory last month in a dredging operation around an island in the San Juan River that has been the source of friction for more than a century.

The International Court of Justice (ICJ) said today Costa Rica filed its case on Thursday. Nicaragua will likely file a reply, and court proceedings of this kind often take many years.

The ICJ is the highest legal authority of the United Nations set up in The Hague in 1946 to resolve disputes between states.

"Costa Rica further contends that 'the ongoing presence of Nicaraguan armed forces on Costa Rica's territory is contributing to a political situation of extreme hostility and tension', and that 'the threat of armed conflict will overshadow the proceedings before the court'," the ICJ said.

Nicaragua's leftist government of president Daniel Ortega, a former Sandinista guerrilla leader, this week denied any incursion into Costa Rican territory and said its troops were on the ground to fight drug trafficking.

The Organization of American States urged Nicaragua and Costa Rica to withdraw their security forces from the disputed river border.

Costa Rica accused Nicaragua of having occupied the territory of Costa Rica to build a canal across Costa Rican territory from the San Juan River to Laguna los Portillos, which is also known as Harbor Head Lagoon, and certain related works of dredging on the San Juan River, the ICJ said.

Costa Rica asked the court for provisional measures pending any trial, such as the withdrawal of Nicaraguan troops and halting the construction of the canal, the ICJ said.