(Reuters) — Facebook reported better-than-expected quarterly revenue on Wednesday and profit rose as growth in expenses slowed from a year earlier, assuaging investor fears of financial fallout from fierce scrutiny by regulators and lawmakers of the world’s largest social media company. Shares rose nearly 3% after hours.

Third-quarter revenue rose 28% compared with a year ago to $17.38 billion, beating analysts’ average estimate of $17.37 billion, according to IBES data from Refinitiv. Facebook reported $6.09 billion in profit, or $2.12 per share. Analysts expected $5.47 billion in profit, or $1.91 per share.

Over the last three years, Facebook has faced rising hostility from both users and lawmakers over its handling of user data and its inability to ensure the integrity of its popular news feeds. It also faces growing regulatory challenges as U.S. authorities investigate whether it has engaged in anti-competitive practices.

Debra Aho, eMarketer principal analyst, said she was “not surprised” by Facebook’s solid results.

“Advertisers continue to support Facebook, despite the many controversies swirling around the company, and the user base also continues to expand around the world,” Aho said in an emailed statement. “Yes, Facebook has a lot of challenges it must deal with, but increasing its revenue and user count isn’t one of them.”

Facebook, the world’s No. 2 seller of online ads, had experienced about 18 months of slow sales growth and elevated spending heading into the third quarter. Concerns over privacy have fueled an acceleration in costs for privacy staff and other roles.

Facebook’s privacy scandals have helped inspire browser makers, operating system vendors and other software companies to provide people with more tools to block the type of online tracking that has been essential to Facebook’s algorithms for targeting ads.

Facebook, Twitter, and Alphabet’s Google have been under pressure to police their platforms after facing criticism for failing to counter alleged Russian interference in the 2016 U.S. presidential election.

In recent weeks, Facebook has come under fire over its decision not to fact-check ads run by politicians on the platform.

Facebook’s existing businesses continued to grow at a fast pace in the first half of the year. But whether it can maintain the momentum has been unclear with newer ventures including privacy-focused messaging services, its expansion into online dating or its burgeoning features for group discussions and eBay-like shopping center.

For the quarter, the company reported 2.8 billion monthly users and 2.2 billion daily users across Facebook, Messenger, Instagram and WhatsApp, both slightly higher than the prior quarter.

Facebook itself had 1.62 billion daily users, versus estimates of 1.61 billion. Monthly active users rose to 2.45 billion, in line with estimates, according to IBES data from Refinitiv.

Facebook also said one of its board directors, Susan Desmond-Hellmann, chief executive of The Bill and Melina Gates Foundation, would be stepping down and that a replacement would be named in the coming months.

Facebook shares have gained about 43.6% this year through Wednesday’s close, thanks to above-expectations revenue in the first half of the year. The company reached a $5 billion settlement in a U.S. Federal Trade Commission probe, which started after its Cambridge Analytica data misuse scandal and threatened to cost the company several more billions.

Even so, shares have not recovered to their record closing high of $194.32 in June 2018, just before a dramatic drop that summer amid escalating costs.

And Facebook still faces extensive regulatory challenges. Its competitive practices are under investigation separately by the U.S. Congress, Department of Justice, FTC, and 47 state attorneys general.

The break-up or tighter regulation of Facebook and other big tech firms over antitrust concerns has also emerged as a key issue for Democratic candidates in the run-up to the November 2020 U.S. presidential election.

Last week, Facebook CEO Mark Zuckerberg was grilled by U.S. lawmakers on issues from its planned digital currency Libra to election interference.

The Libra project has faltered in recent weeks amid sustained criticism from lawmakers and regulators globally over fears it may aid money laundering and upend the global financial system.

Facebook’s total expenses in the third quarter were $10.5 billion, up 32% compared with a year ago. The third-quarter operating margin was 41% from 42% a year ago.