The European Parliament on Wednesday voted to pass a fiercely contested law to restore degraded natural ecosystems, salvaging the environmental measures that centre-right lawmakers had campaigned to kill off.

European Union lawmakers adopted the legal proposal with 336 votes in favour, 300 against, and 13 abstentions. Lawmakers and member countries will now negotiate the final text, aiming for a deal before EU Parliament elections in 2024.

“We have won. It is a social victory: for scientists, for young people, for a lot of companies and businesses, for the agricultural sector,” Cesar Luena, the parliament’s lead negotiator on the law, told reporters after the vote.

The decision comes after months of political campaigning that exposed deep divisions among EU countries and lawmakers over the proposal, with some government leaders warning that Europe is pushing through too many environmental laws as part of its overall green agenda.

The new legislation will require countries to introduce measures restoring nature on a fifth of their land and sea by 2030. The aim is to reverse the decline of Europe’s natural habitats – 81% of which are classed as being in poor health.

“Restoring nature brings numerous benefits to farmers such as revitalising soils, supporting pollinators and buffering them from the worsening impacts of climate change. It is as simple as this: we cannot grow food on dead soil,” EU lawmaker Mohammed Chahim said after the vote.

The European People’s Party (EPP), the EU Parliament’s biggest lawmaker group, led a campaign to reject the plan on the grounds it would harm farmers and endanger food security.

That’s despite Ursula von der Leyen – the head of the European Commission, which proposed the nature law – being from the EPP party.

“We fear that this law will be counterproductive and have significant social and economic consequences,” the EPP group said in a tweet.

Other lawmakers and scientists have rejected the EPP’s claims, accusing the group of using misinformation to court votes ahead of EU Parliament elections next year. The group denies this.

“This law is not against anybody,” Luena said. “This is a law on behalf of nature, not against any person whatsoever.”

Luena thanked the scientists and young people who had supported the law – among them, Swedish activist Greta Thunberg, who attended the EU assembly on Wednesday to watch the vote.

Brussels has already passed dozens of CO2-cutting laws to deliver the EU’s overall green agenda, including its goal to reach net zero greenhouse gas emissions by 2050.

But recent environment proposals have hit resistance – particularly those that would require changes from farmers to tackle environmental pollution and the collapse of bee and butterfly populations.

EU lawmakers voted earlier this week to weaken another law to cut pollution from farms.