Twitter shares took a pounding on Friday after it reported a decline in its user base, extending a stock market bloodbath for what had been a sizzling social media sector.

Shares in Twitter tumbled 20.5 percent to close at $34.12 despite a record profit for the short messaging service, as financial markets focused on the new realities for social media firms moving to curb abusive behavior and boost privacy.

The woes for Twitter came a day after Facebook lost an unprecedented $120 billion in market value following its earnings report that sent investors into a panic over cooling growth for the social network star.

Twitter said it posted a best-ever profit of $100 million in the second quarter, following a loss of $116 million a year earlier. Revenue rose 24 percent to $711 million.

But the San Francisco-based firm said its base of monthly active users fell by one million from the past quarter to 335 million in the period amid a purge of fake and abusive accounts and a crackdown on toxic "bots."

Twitter said it also expected user numbers to drop in the current quarter by a figure in the "mid-single-digit millions."

The fall in users is a result of "prioritizing the health of the platform, and, to a lesser extent, GDPR," Twitter said, referring to Europe's General Data Protection Regulations that limit how internet firms can handle user data.

Wall Street 'off guard'

Analyst Daniel Ives at GBH Insights said markets have abruptly begun to consider "a new risk factor that has been introduced" -- how security and privacy affects the bottom line.

"It got the Street off guard in terms of the magnitude of the effect it had on earnings," Ives said.

Jennifer Grygiel, a Syracuse University professor who specializes in social media , said the market is coming to grips with a tougher picture for the sector as companies seek to curb manipulation and abusive conduct while coping with new regulations on privacy and data protection.

"What you're seeing is a market correction as the industry adjusts for increased operational expenses as governance and ethical business expectations have been raised globally," she said.

"Social media is not going anywhere. What has changed is that the public and regulators are no longer buying into (the) rhetoric and myths that social media is too big to moderate."

Chief executive Jack Dorsey said the past quarter's results reflect investments "in the long-term health" of Twitter, noting efforts to weed out abusive and inappropriate behavior.

"We'll continue to invest heavily in making Twitter a healthier place because that's the right thing to do," Dorsey told analysts on a conference call.

New tools to fight abuse

Dorsey noted that Twitter is investing in "new tools to address problem behaviors that distort and distract from the public conversation."

In recent weeks, Twitter has stepped up efforts to weed out accounts that promote violence or hate speech, and some reports suggested the move could lower the user base by millions.

Earlier this week, Twitter said it had removed more than 143,000 apps from its service since April in a fresh crackdown on "malicious" activity from automated accounts.

Twitter shares had more than doubled over the past year as it showed signs of sustaining profitability after years of losses.

But a lingering concern has been the stalled user base, with Twitter struggling to move beyond its core group of celebrities, journalists and politicians.

Both Twitter and Facebook moved to crack down on bots and fake accounts after learning of efforts to manipulate the social platforms during the 2016 US presidential election.

Dorsey told analysts that Twitter had a "solid quarter" and suggested that daily usage was a better measure of its future growth.

Twitter said daily active users rose 11 percent from a year ago, without giving a specific figure.

Analysts say Twitter has been on a more sustainable track a year after it explored a sale of the company, although its user base is far below that of the 2.2 billion of Facebook and the billion-plus for Facebook-owned Instagram.

But some say Twitter's unique position as a real-time network that allows users to follow news and events will eventually pay off.

Brian Wieser at Pivotal Research Group said efforts to curb fake accounts "should be viewed positively because these efforts improve Twitter's position with regulators and with advertisers, who see the user base as higher quality when purges occur."

RBC Capital Markets analyst Mark Mahaney said in an upbeat note this week that Twitter is "one of the largest and most influential social networks" and provides "meaningful value to users