The number of people using Twitter fell during the three months ending in June as it worked to clean up the platform and comply with new privacy regulations.

The social network said Friday that it had 335 million monthly users around the world in the second quarter, down from 336 million users in the quarter prior. The number of monthly users could also decline by "mid-single-digit millions" in the third quarter, Twitter warned.

The company attributed the dip in part to "decisions we have made to prioritize the health of the platform" and, to a lesser extent, complying with sweeping new data protection regulations in Europe.

The stock fell more than 15% in premarket trading Friday after the earnings results, before rebounding somewhat.

On a conference call with analysts Friday, CEO Jack Dorsey said Twitter would continue to "invest heavily" in improving the health of the platform, calling it the "right thing to do" for the company and "for society as a whole."

"We believe that Twitter's value as a daily service is enhanced when the conversation on the platform is healthier and people feel safe freely expressing themselves," Dorsey said.

Twitter (TWTR) stock has nearly doubled this year as the company showed signs of a business turnaround, its first ever streak of profitable quarters and renewed growth in users and ad sales.

Related: Justin Bieber and Katy Perry among Twitter users hit hardest by follower purge

But the markets were jittery ahead of Friday's report after rival Facebook (FB) spooked investors by warning of slowing sales growth in the second half of the year as it focuses on "putting privacy first."

Twitter has focused on safeguarding the service in recent months amid scrutiny of its role in spreading fake news and election meddling as well as the broader data privacy backlash hitting the tech industry. It cracked down on fake accounts, purging suspicious accounts from users' follower metrics and removed 143,000 apps last quarter for violating its policies.

Like Facebook, Twitter is working to comply with the General Data Protection Regulation, which took effect in Europe in the second quarter. The company said in April that monthly active user growth could be "negatively impacted" by the new rules.

Although user numbers alarmed investors, Twitter's business remains strong. Its sales hit $711 million for the quarter, up 24% from the same period a year ago, and it posted its third consecutive profitable quarter.