France has become the first country in the world to ban supermarkets from throwing away or destroying unsold food, forcing them instead to donate it to charities and food banks.

Under a law passed unanimously by the French senate, as of Wednesday large shops will no longer bin good quality food approaching its best-before date. Charities will be able to give out millions more free meals each year to people struggling to afford to eat.

The law follows a grassroots campaign in France by shoppers, anti-poverty campaigners and those opposed to food waste. The campaign, which led to a petition, was started by the councillor Arash Derambarsh. In December a bill on the issue passed through the national assembly, having been introduced by the former food industry minister Guillaume Garot.

Campaigners now hope to persuade the EU to adopt similar legislation across member states.

The law has been welcomed by food banks, which will now begin the task of finding the extra volunteers, lorries, warehouse and fridge space to deal with an increase in donations from shops and food companies.

Supermarkets will also be barred from deliberately spoiling food in order to stop it being eaten by people foraging in stores’ bins. In recent years, growing numbers of families, students, unemployed and homeless people in France have been foraging in supermarket bins at night to feed themselves. People have been finding edible products thrown out just as their best-before dates approached.

Some supermarkets doused binned food in bleach, reportedly to prevent food poisoning from items taken from bins. Other supermarkets deliberately binned food in locked warehouses for collection by refuse trucks.

Now bosses of supermarkets with a footprint of 400 sq metres (4,305 sq ft) or more will have to sign donation contracts with charities or face a penalty of €3,750 (£2,900).

Jacques Bailet, head of Banques Alimentaires, a network of French food banks, described the law as “positive and very important symbolically”. He said it would greatly increase an already emerging trend for supermarkets to donate to food banks.

“Most importantly, because supermarkets will be obliged to sign a donation deal with charities, we’ll be able to increase the quality and diversity of food we get and distribute,” he said. “In terms of nutritional balance, we currently have a deficit of meat and a lack of fruit and vegetables. This will hopefully allow us to push for those products.”

Until now French food banks received 100,000 tonnes of donated goods, 35,000 tonnes of which came from supermarkets. Even a 15% increase in food coming from supermarkets would mean 10m more meals being handed out each year, Bailet said.

Food banks and charities will, for their part, be obliged to collect and stock the food in properly hygienic conditions and distribute it with “dignity”. This means the food must be given out at a proper food bank or centre, where human contact and conversation is fostered, rather than, for example, simply organised as handoutson the street.

Crucially the law will also make it simpler for the food industry to give some excess products directly to food banks from factories. Until now, if a dairy factory made yoghurts carrying the brand name of a supermarket, it had been a long, complex process to donate any excess to charity. Now it would be faster and easier. “That is very important for food banks because this is a real source of quality products, coming straight from the factory,” Bailet said.

Derambarsh, who is a municipal councillor for Courbevoie, about five miles north-west of Paris, said: “The next step is to ask the president, François Hollande, to put pressure on Jean-Claude Juncker and to extend this law to the whole of the EU. This battle is only just beginning. We now have to fight food waste in restaurants, bakeries, school canteens and company canteens.”

Carrefour, France’s biggest supermarket group, said it welcomed the law, which would build on food donations its supermarkets already made.

France, so far, goes further than the UK, where the government has a voluntary agreement with the grocery and retail sector to cut food and packaging waste in the supply chain and does not have mandatory targets. However, a UK food waste bill, with similar provisions, was introduced to the Commons last September by the Labour MP Kerry McCarthy.

Of the 7.1m tonnes of food wasted in France annually, 67% is binned by consumers, 15% by restaurants and 11% by shops. Each year 1.3bn tonnes of food are wasted worldwide.

A report published in 2015 showed that UK households threw away 7m tonnes of food in 2012, enough to fill London’s Wembley stadium nine times over. Avoidable household food waste in the UK is associated with 17m tonnes of CO 2 emissions annually.

• This article was amended on 8 February 2016 to correct the penalty that could be imposed on supermarkets that flout the law. An earlier version gave this as fines of up to €75,000 (£53,000) or two years’ imprisonment.