SAN FRANCISCO — Facebook said on Tuesday it had removed hundreds of Iran-based pages, groups and accounts, alleging that they formed a network linked to Iranian state media that covertly spread political content to people on four continents including in the U.S.

Facebook said in a blog post that the 652 pages, groups and accounts were in violation of its terms of service because they were engaged in "coordinated inauthentic behavior." Facebook generally requires people to use their real names on the social network.

Twitter followed suit, saying it had suspended 284 accounts for engaging in "coordinated manipulation" on its network and that many of the accounts had originated in Iran.

The announcements add to a steady drumbeat of efforts by U.S. tech companies to detect and stop hacking attempts by suspected foreign agents who might want to meddle in the Nov. 6 midterm elections.

"You're going to see people try to abuse the services in any way possible," Facebook CEO Mark Zuckerberg said on a conference call with reporters.

"We need to make sure that we're continuing to strengthen the security operations that we have," Zuckerberg said, adding that Facebook had other investigations ongoing that he could not yet disclose.

We also learned today that the Iranians are now following the Kremlin’s playbook from 2016. — Mark Warner (@MarkWarner) August 21, 2018

Earlier on Tuesday, Microsoft said it had shut down six websites created by a group tied to Russian intelligence that sought to spoof conservative U.S. institutions as well as the U.S. Senate. Russian authorities denied the allegations.

Facebook said last month that it had removed 32 pages and accounts from its platform and from Instagram that the company said were trying to covertly spread divisive political messages.

On Tuesday, Facebook said its investigation into the Iran-based pages began with a tip in July from FireEye, a private security firm. FireEye published its own preliminary findings on its website.

Samples of the posts in question, released by Facebook, showed that the pages posted on an array of divisive global topics such as Britain's planned exit from the European Union, U.S. relations with North Korea and the Israeli-Palestinian conflict.

Facebook said its investigation was continuing and that the company had shared its findings with U.S. and British authorities.

One part of the Iran-based network, going by the name "Quest 4 Truth," claimed to be an independent Iranian media organization but was in fact linked to Iranian state media, Facebook said. Other accounts used the name "Liberty Front Press," the company said.

Some of the accounts attempted to hack other people's accounts and spread malware, Facebook said. It said the company had been able to disrupt the attacks.

The company was not in a position to assess the motives of the people behind the accounts, Nathaniel Gleicher, Facebook's head of cybersecurity policy, told reporters.

The investigation may have implications for how the social media company complies with U.S. sanctions on Iran.

Facebook said that because of the sanctions it takes steps to prevent people in Iran from using its advertising tools, and that the accounts in question had purchased more than $12,000 in ads on Facebook and Instagram.

"We'll make changes to better detect people who try to evade our sanctions compliance tools and prevent them from advertising," Gleicher said in the blog post.

Separate from the Iran-based pages, Facebook said it had removed more pages, groups and accounts that it said could be linked to sources identified by the U.S. as Russian military intelligence services.

The Russia-linked accounts most recently focused on politics in Syria and Ukraine, not in the U.S., Facebook said, although the company said it was working with U.S. law enforcement. It did not disclose the number of accounts it took down or their names.