BRUSSELS - Facebook, Twitter, Google's YouTube, and Microsoft on Tuesday agreed to an EU code of conduct to tackle online hate speech within 24 hours in Europe.

EU governments have been trying in recent months to get social platforms to crack down on rising online racism following the refugee crisis and terror attacks, with some even threatening action against the companies.

As part of the pledge agreed with the European Commission, the web giants will review the majority of valid requests for removal of illegal hate speech in less than 24 hours and remove or disable access to the content if necessary.

They will also strengthen their cooperation with civil society organizations who help flag hateful content when it goes online and promote "counter-narratives" to hate speech.

"The recent terror attacks have reminded us of the urgent need to address illegal online hate speech. Social media is unfortunately one of the tools that terrorist groups use to radicalize young people," EU Justice Commissioner Vera Jourova said.

Germany got Google, Facebook and Twitter to agree to delete hate speech from their websites within 24 hours last year and even launched an investigation into the European head of Facebook over its alleged failure to remove racist hate speech.

Microsoft CEO Satya Nadella addresses the media during an event in New Delhi September 30, 2014. REUTERS/Adnan Abidi

"There's no place for hate speech on Facebook," said Monika Bickert, Head of Global Policy Management at Facebook.

"With a global community of 1.6 billion people we work hard to balance giving people the power to express themselves whilst ensuring we provide a respectful environment."

The code of conduct is largely a continuation of efforts that the companies already take to counter hate speech on their websites, such as developing tools for people to report hateful content and training staff to handle such requests.

Twitter has suspended over 125,000 accounts since the middle of 2015 for threatening or promoting terror acts, primarily related to Islamic State.

The United States has undertaken similar efforts to entice the cooperation of tech companies in combating online radicalization, focusing on promoting "counter-narratives" to extremist content.

EU ministers had called for cooperation with tech companies to be stepped up after the Brussels attacks in March.

Jewish lobbyists, frequently the target of hate speech, welcomed the code of conduct.

"This a historic agreement that could not arrive at a better time,” said Dr. Moshe Kantor, President of the European Jewish Congress.

(Editing by Alexandra Hudson)