A German court has ordered Tesla to stop clearing forest land near the capital Berlin to build its first European car and battery factory, a victory for local environmental activists. 

The US electric carmaker announced plans last November to build a gigafactory in Gruenheide in the eastern state of Brandenburg.  

The court ruling, 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 of forest for the plant. 

Planning permission has not yet been granted to build the Gigafactory, however, meaning US entrepreneur 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 Gruene Liga Brandenburg (Green League of Brandenburg). 

"It should not be assumed that the motion seeking legal protection brought by the Green League lacks any chance of succeeding," the court statement added. 

Lawmakers from the pro-business Christian Democrat and Free Democrat parties have warned that the legal battle waged 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 what they say is the threat it poses to local wildlife and water supplies. 

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

Tesla shares have surged 340% since early June as more investors bet on Musk's vision.