Facebook, Twitter, YouTube and Microsoft are teaming up with the European Union to crack down on online hate speech.

The internet giants signed up to a new set of rules designed to stop racist, violent and illegal content from going viral. They agreed to review a "majority" of flagged content within 24 hours. They'll remove it, if necessary.

They also pledged to train their staff and work with each other to tackle the problem.

Vera Jourova, the EU justice commissioner in charge of the issue, said tackling illegal online hate speech is becoming more urgent.

"Social media is unfortunately one of the tools that terrorist groups use to radicalize young people and racists use to spread violence and hatred," she said.

The companies also agreed to promote "independent counter-narratives" to fight hate speech, including content promoting non-discrimination, tolerance and respect.

Related: Microsoft goes to battle against terrorists online

Most of the companies already have their own rules and community standards in place.

Earlier this year, Twitter (TWTR) expanded the team that reviews reports of terror activity on the network. Twitter said in February that it has shut down 125,000 accounts for threatening or promoting terrorist acts in just seven months. Most of the people behind the accounts were affiliated with or supported ISIS, Twitter said.

"We work hard to balance giving people the power to express themselves whilst ensuring we provide a respectful environment," said Monika Bickert, the head of Global Policy Management at Facebook. "We urge people to use our reporting tools if they find content that they believe violates our standards so we can investigate."

Facebook (FB) said it gets as many as 1 million violation reports from users every day.

Related: Twitter crackdown on hate speech backfires

Microsoft (MSFT) changed its terms of use last week "to specifically prohibit the posting of terrorist content on [its] hosted consumer services," such as OneNote, a cloud-based document program.

Big tech companies have also met U.S. government officials earlier this year to discuss how to stop ISIS from recruiting terrorists on social media. The Obama administration had asked the companies to develop techniques to detect radicalization, and block pro-ISIS messages, photos and videos.