Environmentalists had been living in the last remnant of the ancient forest, located between the western cities of Cologne and Aachen, for years in a bid to stop it being destroyed to make way for the extension of an open-cast lignite mine.
The activists argued that expanding the mine and clearing the environmentally valuable forest were pointless in view of Germany's intention to abandon using coal as an energy source by 2038 at the latest.
The court said that the argument used by authorities at the time — that the treehouses violated rules on fire safety — was a pretext for removing the activists and preventing them from stopping the expansion of the mine.
The ruling came in response to a complaint by one former treehouse resident, according to the German DPA news agency.
Order from on high
The order to clear the forest originally came from the government of North Rhine-Westphalia (NRW), the state in which the forest is situated, though the city of Kerpen and the district of Düren were charged with carrying out the clearance.
The police operation, one of the largest-ever in the state, to clear the forest in September 2018 drew massive media attention. The death of a journalist who fell through a walkway between the trees added to the widespread public outrage, though the accident was not a direct result of the authorities' action. In all, 86 treehouses were removed.
Activists have since moved back into the forest. For the time being, the forest is safe, with no current plans to clear it for the mine's expansion.
The Hambach surface mine, operated by energy giant RWE, is the largest of its kind in Europe. The company has argued that removing the forest was necessary to meet Germany's energy needs. A number of villages have also fallen victim to the mine and its continued expansion.
The court's ruling is not final and can be appealed by all parties.