The European Commission had proposed the law in 2018, worried about the role of such content after a series of attacks by radicalised lone-wolf attackers in several European cities.

The EU executive defines online terrorist content as material inciting terrorism or aimed at recruiting or training terrorists as well as material that provides guidance on how to make and use explosives and firearms for terrorist purposes.

The European Parliament approved the law late on Wednesday.

Lawmaker Patryk Jaki said the legislation "balances security and freedom of speech and expression on the internet, protects legal content and access to information for every citizen in the EU, while fighting terrorism through cooperation and trust between states".

The companies can face fines up to 4% of their global turnover for non-compliance. They have said they shared regulators' efforts to tackle the issue and keep the content off their platforms.

Some lawmakers who had opposed the law warned of far-reaching consequences.

"We really are risking censorship across Europe. Hungarian and Polish governments already demonstrated they have no issues removing content that they disagree with," Vice President of the European Parliament Marcel Kolaja said.

"This regulation allows them to spread these practices to the territory of any other member state," he said.

Civil rights groups, which had campaigned to get lawmakers to reject the legislation, criticised the procedure, saying that the legislation had been approved with no final vote by the assembly.

They said the new rule could bolster authoritarian governments.

"As the state of the rule of law in Europe is continuously deteriorating, the EU is giving further sweeping powers to law enforcement authorities to crack down on legitimate protests, freedom of expression, and media and artistic freedoms online," said Anna Mazgal, EU policy adviser at Wikimedia Deutschland.

The law will come into force 20 days after it is published in the EU Official Journal.

(Reporting by Foo Yun Chee; Editing by Alison Williams)

By Foo Yun Chee