The legislation will remove palm oil from a list of permitted biofuels from January 2020 and eliminate related tax advantages.

Total invested 300 million euros to convert its La Mede site from a crude oil refinery into a biofuel plant, starting output in July.

CEO Patrick Pouyanne has warned that if the law were upheld, it could mean losses of up to 80 million euros for the refinery, forcing the company to rethink its plans.

The constitutional court said in a statement the law was in line with the public interest of environmental protection, "considering the strong growth of palm oil production and the major amount of land used for its production worldwide, and given the deforestation and drying out of peat bogs".

A spokesman said Total had taken note of the court's decision and reiterated Pouyanne's previous comments that the company would not be able to meet an agreement with the government to source some feed stock locally if the law was upheld.

Pouyanne told lawmakers during a hearing in September that Total had no wish to shut down La Mede, which employs around 300 people.

However, he said that the company would not be able to meet commitments such as buying rapeseed oil from French farmers for the refinery.

"We would have to look for an export market, but the refinery will not be competitive," he said last month.

The European Union also plans to restrict the use of palm oil in biofuel due to the environmental impact, something which has triggered diplomatic tensions with top producers Malaysia and Indonesia.

TAX EXEMPTIONS

Under the French government's 2019 budget, tax exemptions for palm oil will end on Jan. 1, 2020. The law specifies that palm oil cannot be considered a biofuel unless producers can guarantee it has been produced under conditions that prevent an indirect increase of greenhouse gas emissions.

Tax exemptions for other biofuels remain in place.

Total argues that adding palm oil to fuel is a way of using renewable energy and that the budget law introduced an unjustifiable difference between palm oil and other oilseed crops.

The company won government approval in 2018 to use palm oil to supply La Mede. It pledged that palm oil would account for less than half of raw material used, with French rapeseed crops and recycled oil also being used. However, the plans caused uproar among environmental activists and farmers.

Environmental protection group Greenpeace welcomed the court's decision as "good news for the fight against deforestation" and called in a statement for France to also remove soybeans from the list of crops approved for biofuel.

(Reporting by Geert De Clercq, additional reporting by Gus Trompiz; Editing by Dale Hudson and Kirsten Donovan)