Facebook's fortunes shifted in under two hours.

(Reuters) - Facebook Inc's shares lost as much as a quarter of their value on Wednesday after executives said that profit margins would plummet for several years due to the costs of improving privacy safeguards and slowing usage in the biggest advertising markets.

The second-quarter results were the first sign that a new European privacy law and a succession of privacy scandals involving Cambridge Analytica and other app developers have bit into Facebook's business. The company further warned that the toll would not be offset by revenue growth from emerging markets and Facebook's Instagram app, which has been more immune from privacy concerns.

Facebook's fortunes shifted in under two hours as the company first reported revenue and user growth that missed expectations and then issued warnings about future growth and expenses.

Operating profit margin, which fell to 44 percent in the second quarter from 47 percent a year ago, will sink to the "mid-30s" for more than two years, Chief Financial Officer David Wehner said in investor guidance.

The plummeting stock price wiped out as much as $150 billion in market capitalization and erased the stock's gains since April when Facebook announced a surprisingly strong 63 percent rise in profit and an increase in users.

If the share drop holds on Thursday, it would be Facebook's largest single-day decline, topping a 12 percent decrease in July 2012.

Gloomy forecast for revenue growth

Facebook had cautioned investors to expect a big jump in second-quarter costs because of efforts to address concerns about poor handling of users' privacy and to better monitor what users post. Total expenses in the second quarter surged to $7.4 billion, up 50 percent compared with a year ago.

Facebook forecast similar increases for the second half of the year, also citing spending on video content and marketing.

Its gloomy forecast for revenue growth surprised investors, though, and prompted many questions from financial analysts on a conference call with company executives on Wednesday.

Sales in the second quarter grew 42 percent, its slowest pace in nearly three years, to $13.2 billion compared with $9.3 billion a year ago.

They're talking about currency headwinds, but more we think it's due to slower user growth given GDPR and more focus on privacy.Ali Mogharabi, Morningstar

Wehner said quarterly revenue growth would be closer to 30 percent the rest of the year.

He cited currency fluctuations and a shift in usage to features where Facebook shows less advertising or charges less due to lower demand.

The General Data Protection Regulation (GDPR) in the European Union also will cause a revenue drop. The new privacy law forced several changes to Facebook's privacy terms and sign-up process, leading a minority of users to opt for non-personalized ads, which tend to generate less revenue.

"They're talking about currency headwinds, but more we think it's due to slower user growth given GDPR and more focus on privacy," Morningstar analyst Ali Mogharabi said.

'Entering a new period'

Facebook's daily active users in Europe declined by 3 million amid the new regulation. Worldwide daily user growth for Facebook's namesake service slid for its sixth straight quarter, bringing it to nearly 1.5 billion users in the second quarter.

The company said for the first time that more than 2.5 billion users interact with at least one of its apps each month, but analysts have said many of them are spending more time with Messenger, WhatsApp and Instagram. Commercialization of those apps is nascent.

Revenue from emerging markets has not picked up the slack either. Sales from United States, Canada and Europe fell $75 million in the second quarter compared with a year ago, while revenue from other markets rose $51 million.

Gene Munster, a venture capitalist at Loup Ventures, said in an email that Facebook is "entering a new period" where declining user growth will translate to slower revenue growth.

He added that Facebook has "a track record of resetting revenue growth and expense expectations only to turn around and exceed those expectations the following quarter."

Facebook reported $5.1 billion in profit, or $1.74 per share, compared with the average estimates of $5.1 billion and $1.72 per share among research gathered by Thomson Reuters.

Facebook out from China, again

The threat of additional privacy regulatory setbacks remains a concern, according to analysts.

Facebook suffered a blow in China on Wednesday when regulators there withdrew their approval of a company innovation hub to support local startups, the New York Times reported on Wednesday, citing a person familiar with the matter.

Misinformation on WhatsApp contributing to mob killings in India have added to the pressure onFacebook to re-evaluate how its services maintain security and decorum.

Nearly all social media services have received greater scrutiny since U.S. intelligence agencies in January 2017 revealed that organizations tied to the Russian government had seeded content on the platform to shake up the 2016 U.S. presidential election.