Through scandal and turmoil, Facebook had taken on an air of invincibility, with its user base continuing to grow and ad dollars fueling its steadily rising stock price. That all came crashing down on Wednesday.

Shares in Facebook plunged more than 20 percent in after-hours trading after the social network warned that it would be less profitable in the years ahead due to shifts in its ad business.

Facebook also reported that its user base in Europe had shrunk because of a new privacy law there, marking one of the few times in the social network’s history that it has reported a user decline in any region.

The results marked a rare disappointing day for investors in Facebook, which for years has regularly beaten analysts’ expectations for revenue growth and profit margins despite concerns about the long-term impact of privacy scandals.

Facebook shares dropped 20.4 percent from their closing price on Wednesday, reaching a level last seen when Facebook was mired in a scandal over data that ended up in the possession of political consulting firm Cambridge Analytica.

The nosedive wiped out more than $120 billion in market value.

The lone bright spot came in the form of a new metric introduced by Facebook: a “family audience” of 2.5 billion people. Facebook said that family audience measures how many people it counts across all of its apps, including the main Facebook app, Facebook Messenger, WhatsApp and Instagram.

Facebook Chief Financial Officer David Wehner told investment analysts on a conference call that the company’s operating margin, a key measure of profit, would trend toward the “mid-30s” over the next several years, down from 44 percent in the quarter that ended June 30.

Pressed by analysts who expressed surprise at the warning, Wehner said that operating margin would be hurt by factors including currency exchange rates and the introduction of new advertising products like the “stories” feature on Facebook and Instagram.

Facebook also suffered a rare regional decrease in the number of users, as its base of daily users in Europe fell from 282 million at the end of March to 279 million at the end of June. Wehner said the drop was due entirely to a data protection and privacy law that took effect in Europe in May known as the General Data Protection Regulation, or GDPR.