BERLIN — Farmers in Germany will have to gradually reduce their use of glyphosate and stop using it completely from 2024 in order to preserve clean habitats for insects, under draft legislation passed by the country’s cabinet on Wednesday.

“The exit from glyphosate is coming. Conservationists have been working toward this for a long time. Glyphosate kills everything that is green and takes away insects’ basis for life,” environment minister Svenja Schulze said in a statement.

Farmers have criticized the planned law, saying it puts the livelihoods of family-run farms at risk and that bans would be less effective in fostering biodiversity than cooperation between farmers and conservationists.

Glyphosate, first developed by Bayer’s Monsanto under the Roundup brand, has generated intense global debate over its safety since a World Health Organization agency concluded in 2015 that it probably causes cancer.

While regulators worldwide have determined glyphosate to be safe, Bayer agreed in June to settle nearly 100,000 U.S. lawsuits for $10.9 billion, denying claims that Roundup caused cancer.

Under the draft German legislation, the use of herbicides and insecticides that could harm bees will be banned from certain areas. In addition, new installations of certain types of lights will be forbidden to reduce light pollution.

Joachim Rukwied, head of the German farmers’ association, said the proposed legislation was the wrong way to achieve more environmental protection, adding: “A partnership between agriculture and conservation, with joint goals, measures and incentives, would be more promising.”

The law needs to be passed by both the Bundestag lower house and the Bundesrat upper house which represents the interests of the 16 regional governments in Germany, a process that typically takes several months.