A court in Ecuador has upheld a ruling that prevents the government from selling land in the Amazon rainforest to oil companies, a move activists called a historic win for the Waorani indigenous tribe living there.

The government had appealed an earlier court ruling in April that the 2,000-strong tribe had not been properly consulted over plans to auction their ancestral lands to oil companies.

The decision late on Thursday from Pastaza province in the eastern Amazon to uphold the ruling ends the years-long legal battle over the land, campaigners said.

“This victory is for my ancestors. It’s for our forest and future generations. And it’s for the whole world,” said Nemonte Nenquimo, president of the Waorani Pastaza Organization on Friday.

Ecuador’s energy ministry — a respondent in the case — was not immediately available to comment.

The ministry said in April that the government had carried out a proper consultation process with the Waorani according to the “law and international standards.”

The ruling could set a precedent for other tribes opposed to drilling, campaigners said.

Ecuador is pushing to open up more rainforest and develop its oil and gas reserves in the hope of improving its sluggish economy and cutting its high fiscal deficit and foreign debt.

Tensions have simmered between indigenous communities and oil companies in Ecuador since Texaco — now Chevron — began operations in the Amazon in the 1960s.

The constitution gives the government the right to develop energy projects and extract minerals on any land, regardless of who owns it, but requires that communities are first consulted and properly informed about any projects and their impact.

This week’s ruling protects half a million acres of land in the Amazon forest on which the Waorani have lived for centuries from being earmarked for oil drilling, campaigners said.

It “permanently voids the consultation process with the Waorani undertaken by the Ecuadorian government in 2012, indefinitely suspending the auctioning of their lands,” said campaign group Amazon Frontlines, which supported the Waorani.

The head of Amazon Frontlines Mitch Anderson said the win “shows once again that the fate of the Amazon rainforest, and consequently our climate, hinges on whether or not indigenous people can continue to protect their rainforest territories and cultures.”