Facebook has cracked down on 30,000 fake accounts in France ahead of the country's pivotal presidential election. Facebook said the accounts were spreading fake news stories, spam, misinformation or other deceptive content.

"Our priority, of course, is to remove the accounts with the largest footprint, with a high amount of activity and a broad reach," Facebook security manager Shabnam Shaik said in a blog post.

The social media giant acknowledged, however, that the purge will not remove all accounts that are spreading fake news. "We know we have to keep getting better," said Shaik.

"These accounts were targeted because they are fake. Full stop," a Facebook spokesman told CNNTech. He said that taking down fake accounts helps prevent hoaxes, spam, political trolling and fake news.

"We routinely focus on these types of improvements. It's an ongoing effort and challenge," he said.

The spread of fake news has raised concerns in France ahead of the country's national elections. The first round of the voting, scheduled for April 23, will feature candidates including far right National Front leader Marine Le Pen.

Le Pen is expected to perform well enough to earn a place in a runoff scheduled for May 7.

Facebook on Thursday also took out newspaper ads with tips for spotting fake news in major publications in France and Germany.

Related: Europe's lost generation: Young, educated and unemployed

The crackdown by Facebook (FB) represents a major shift in policy from only a few months ago, when the role of fake news in electoral politics came under scrutiny following Donald Trump's surprise victory.

Immediately following the vote, Facebook CEO Mark Zuckerberg said his company was not responsible for influencing people's votes.

"Personally, I think the idea that fake news on Facebook -- of which it's a small amount of content -- influenced the election in any way is a pretty crazy idea," he said.

Related: Facebook, Twitter face fines up to $53 million over hate speech

But public pressure has forced Facebook and other social media companies to rethink their role in the public debate, and many have implemented measures in recent months designed to discourage the spread of fake news.

Facebook recently began warning users that certain stories have been "disputed by fact checkers." It has also made it easier for users to report fake news and sought to undercut the business model used by publishers of fake news.

In France, media newsrooms have partnered with Google News Lab and the nonprofit First Draft News to identify and quickly debunk hoaxes and false claims as part of a program called "CrossCheck."

The initiative has debunked dozens of fake news and myths since it started in early February.

Germany, which will also hold national elections later this year, has also cracked down on fake news.

The German cabinet approved a plan earlier this month to start fining social media companies as much as as €50 million ($53 million) if they fail to quickly remove posts that breach German law.

CNNTech's Kaya Yurieff contributed to this story.