The court said indigenous groups were in grave danger due to Colombia's armed conflict.
The Constitutional Court ordered the Armed Forces to dismantle a training base built on land belonging to indigenous tribes in Guaviare province.
|The Colombian government says it will challenge a court decision which ruled against the military in a land dispute.
The court said the tribes' rights were being violated by being caught in the middle of the armed conflict between the security forces and rebel groups.
The government said that it would try to get the decision reversed.
The ruling comes just weeks after the security forces clashed with members of another indigenous group in south-western Colombia over demands that the army leave their land.
In Thursday's ruling, the Constitutional Court said that the Jiw and Nukak indigenous groups were "in grave danger of being physically and culturally exterminated due to the internal armed conflict and the failure of the authorities to give them adequate protection".
The court said that three indigenous people had been injured by unexploded ammunition and landmines around the training base in Barrancon.
According to the Colombian Institute of Rural Development the training base and its 19 buildings occupy about six hectares (12.4 acres) of indigenous land.
|Pictures of Nasa men dragging a soldier angered many Colombians
The base is used to train members of the Navy and the Special Forces.
Commander of the Armed Forces Gen Alejandro Navas said the military should not be seen as an invading force. "We're fulfilling our constitutional duty of ensuring the security of Colombia," he said.
Gen Navas said that members of Colombia's largest rebel group, the Farc, and criminal groups were active in the region.
He said that if the Armed Forces pulled out of the area, it would open a strategic corridor for the rebels.
"Members of the Eastern Bloc (of the Farc) will be able to link up with those of the Western Bloc and with the 16th Front," he said.
Gen Navas said the government would fight the decision in court.
Earlier, Defence Minister Juan Carlos Pinzon had said that the Armed Forces would abide by the ruling but would try all legal avenues to have the decision reversed.
Mr Pinzon also said that the ruling had no bearing on the situation in south-western Cauca province, where members of the Nasa indigenous group have demanded that the security forces leave their territory.
Two weeks ago, the Nasa drove a group of soldiers from the military base they were guarding near Toribio.
Pictures of the soldiers being dragged down the mountain by members of the indigenous group prompted a heated debate about the presence of the armed forces on indigenous lands.
Mr Pinzon said the two situations "were totally unrelated" and pointed out that the court case predated the protests in Cauca province.
But Nasa indigenous leader Marcos Yule said the ruling set an important precedent.
"This is useful for us because it confirms we have rights which are being violated," Mr Yule said.
The Nasa have demanded that both the army and the rebels leave their territory and take their fight elsewhere.