(Bloomberg) -- WhatsApp banned hundreds of thousands of accounts in Brazil as the Facebook Inc. messaging service struggles to contain spam, misinformation and other political shenanigans ahead of a runoff election in Latin America’s largest country.

“We have cutting-edge technology to detect spam that identifies accounts with abnormal behavior so that they can’t be used to spread spam or misinformation," a WhatsApp spokesperson wrote in an email. "We are also taking immediate legal measures to prevent companies from sending mass messages via WhatsApp and have already banned accounts associated with those companies."

Facebook set up a "war room" to spot and eradicate misinformation, hate speech and other damaging content during Brazil’s election this month. It’s a test for the social network ahead of midterm elections in the U.S. later this year. While the company said it was able to thwart false information on its main social network, it’s had more trouble controlling misbehavior on WhatsApp, which is encrypted and virtually impossible to monitor.

Brazil’s runoff election is Oct. 28, when far-right politician Jair Bolsonaro faces leftist Workers’ Party candidate Fernando Haddad. On Thursday, the latter accused his competitor of receiving illegal and undeclared corporate donations after local newspaper Folha de S.Paulo reported companies are paying for a mass social media campaign against Haddad. Bolsonaro wrote on Twitter that his opponent’s party “isn’t being damaged by fake news, but rather by the TRUTH.”

WhatsApp said on Friday that it’s taking the accusation seriously. "We are committed to reinforcing WhatsApp policies equally and in a fair way to protect the users’ experience," it added.

WhatsApp confirmed that it blocked the account of Bolsonaro’s son Flavio for spam a couple of days ago. The company said it was unrelated to the accusations on Thursday. It also noted that it banned an account related to former Brazil president Dilma Rousseff, a member of the Workers’ Party.

To contact the reporters on this story: Sarah Frier in San Francisco at sfrier1@bloomberg.net;Giulia Camillo in Sao Paulo at gcamillo@bloomberg.net

To contact the editors responsible for this story: Jillian Ward at jward56@bloomberg.net, Alistair Barr, Molly Schuetz

©2018 Bloomberg L.P.