Illegal factories hidden in the Cambodian rainforest that were producing a raw ingredient for the drug ecstasy have been tracked down and destroyed by investigators from an international environmental agency, working with the Cambodian authorities.

In a month-long investigation the team from Fauna and Flora International (FFI) uncovered the illegal distilleries deep in the forest of the Cardamom mountains in south-west Cambodia.

The two new facilities were intended to make sassafras oil from the roots of the extremely rare Mreah Prew Phnom tree for export to neighbouring countries.

Sassafras oil is used to make cosmetics, but it can also be used as a precursor chemical to make methylenedioxymethamphetamine, more commonly known as the recreational drug ecstasy.

FFI was alarmed that the rate of the illegal production of the "ecstasy oil" could have wiped out the Mreah Prew Phnom tree within five years. The trees are felled and the excavated roots mechanically shredded and boiled in a cauldron during a process that takes about 12 hours to produce 30 litres of oil.

Surrounding trees are also felled to fuel fires for the distillation, threatening one of the last great rainforests in south-east Asia. Rivers are polluted by the effluent from the oil production.

The two factories were discovered last month during the investigation by FFI staff working with Cambodia's environment ministry, which called in the army.

The factories run by Vietnamese syndicates in the Phnom Samkos Wildlife Sanctuary were destroyed and two people arrested. Sassafras oil production is illegal in Cambodia.

Last year 33 tonnes of sassafras oil that FFI helped to seize was destroyed by the Cambodian government and the Australian police, who claimed it could have been used to produce 245m ecstasy tablets with a street value of £4.82bn.

The environmental group first became involved in efforts to crack down on sassafras oil production in 2004 because of the alarming levels of deforestation. In the Phnom Samkos sanctuary FFI now supports 49 Cambodian environment ministry rangers who have closed dozens of factories.

FFI staff estimate there were 75 sassafras oil distilleries operating in the sanctuary at the industry's height in 2006. The number has plummeted, but tight monitoring is vital to prevent a fresh upsurge.

"The re-emergence of the sassafras factories in Phnom Samkos wildlife sanctuary is of enormous concern to us," said FFI field coordinator, Tim Wood. "Recent law enforcement operations clearly show that this threat still persists and that we must remain very vigilant in our effort to suppress this and other forest crimes.

But the policing of the illegal trade is under threat from funding cuts and FFI is calling on the Cambodian government and international donors to support the work of the rangers in combating the production.