Social media companies face fines of up to €50m (£43m) if they persistently fail to remove illegal content from their sites under a new law passed in Germany

The German parliament on Friday approved the bill aimed at cracking down on hate speech, criminal material and fake news on social networks – but critics warn it could have drastic consequences for free speech online.

Germany has some of the world’s toughest laws covering defamation, public incitement to commit crimes and threats of violence, with prison sentences for Holocaust denial or inciting hatred against minorities.

The measure requires social media platforms to remove obviously illegal hate speech and other postings within 24 hours after receiving a notification or complaint, and to block other offensive content within seven days.

The German justice minister, Heiko Maas, who was the driving force behind the bill, said: “Freedom of speech ends where the criminal law begins.” Maas said official figures showed the number of hate crimes in Germany increased by more than 300% in the last two years.

Social media platforms such as Facebook, Google and Twitter have become a battleground for angry debates about Germany’s recent influx of more than 1 million refugees.

The issue has taken on more urgency as German politicians worry that proliferating fake news and racist content, particularly about migrants, could sway public opinion in the run-up to a national election on 24 September.

Maas claimed that 14 months of discussion with major social media companies had made no significant progress. Last week, politicians from his Social Democratic party and the chancellor, Angela Merkel’s centre-right Union bloc agreed a number of amendments to give companies more time to check whether posts that are flagged to them are illegal, delegate the vetting process to a third party and ensure that users whose comments are removed can appeal the decision.

Aside from the hefty fine for companies, the law also provides for fines of up to €5m for the person each company designates to deal with the complaints procedure if it doesn’t meet requirements.

Social networks also have to publish a report every six months detailing how many complaints they received and how they dealt with them.

Among those welcoming the law was Germany’s main Jewish organisation, which called it a “strong instrument against hate speech in social networks”.

Germany has long had a law criminalising Holocaust denial – a response to the country’s Nazi-era history of allowing racist ideas to become genocidal policy.

“Jews are exposed to antisemitic hatred in social networks on a daily basis,” the Central Council of Jews said. “Since all voluntary agreements with platform operators produced almost no result, this law is the logical consequence to effectively limit hate speech.”

The nationalist Alternative for Germany party, which has frequently been accused of whipping up sentiments against immigrants and minorities, said it is considering challenging the law in Germany’s highest court.

Human rights experts and the companies affected say that the law risks privatising the process of censorship and could have a chilling effect on free speech. The government has softened the legislation by excluding email and messenger providers and opening up the option of creating joint monitoring facilities to make decisions about what content to remove.

It also made clear that a fine would not necessarily be imposed after just one infraction, but only after a company systematically refused to act or does not set up a proper complaint management system.

Facebook said in a statement: “This law as it stands now will not improve efforts to tackle this important societal problem.

“We feel that the lack of scrutiny and consultation do not do justice to the importance of the subject. We will continue to do everything we can to ensure safety for the people on our platform,” the company said, noting that it is hiring 3,000 additional staff on top of 4,500 already working to review posts.

The Associated Press and Reuters contributed to this report