A German court has ordered Tesla to stop clearing forest land near Berlin to build its first European car and battery factory, in what is being hailed as a victory for environmental activists.

The US electric carmaker announced plans last November to build a “Gigafactory” in Grünheide in the eastern state of Brandenburg.

The ruling on Sunday, by the higher administrative court of the states of Berlin and Brandenburg, comes after the state environmental office gave a green light to clear 92 hectares (227 acres) of forest for the plant.

Planning permission has not yet been granted to build the Gigafactory, however, meaning Elon Musk’s company is preparing the ground at its own risk.

In a statement, the court said it had issued the order to stop the tree-felling because it would have only taken three more days to complete the work. Otherwise the clearance would have been completed before judges made a final decision on the complaint brought by a local environmentalist group called the Grüne Liga Brandenburg (Green League of Brandenburg).

The court statement said: “It should not be assumed that the motion seeking legal protection brought by the Green League lacks any chance of succeeding.”

Lawmakers from the pro-business Christian Democrat and Free Democrat parties have said the legal action against the Gigafactory would inflict serious and long-lasting damage on Germany’s image as a place to do business.

Local and national lawmakers have been caught out by the strength of opposition to the Gigafactory, with hundreds of demonstrators protesting over the threat they say it poses to local wildlife and water supplies.

Tesla currently has two Gigafactories in the US and one in Shanghai, China.