“This law does not solve all problems, but it is an important step in the fight against hate crimes and punishable fake news in social networks,” said Germany’s justice minister, Heiko Maas. “Our experiences have clearly shown that without political pressures, the social networks will not change.”

Germany has staked out a stance that's among the most vigorous in the world against spurious posts and comments on social media. It also has some of the strictest laws regulating forms of expression seen as encouraging violence. Denying the Holocaust and stirring hatred against minorities are punishable with prison time.

In the past two years, Maas said, hate crimes in Germany increased by more than 300 percent. Now, German officials are cracking down on the shadowy online networks they believe incite this activity.

Under the new measure, which takes effect in October, companies have 24 hours to erase illegal content after it is flagged. They have another seven days to sift through messages marked as offensive but not necessarily criminal under German statute. Fines for consistently failing to respond begin at 5 million euros, about $5.7 million, but may go as high as 50 million euros.

Facebook, which recently expanded the number of employees charged with reviewing flagged content, criticized the legislation in a statement, saying it “will not improve efforts to tackle this important societal problem.”

If successful, the law could become a model elsewhere. That has international digital freedom groups worried. A Brussels-based organization, European Digital Rights, warned that the law “could seriously impair human rights online,” assailing the European Union for not intervening to challenge it.