It was “the fourth straight quarter that the social media giant has delivered sub-30 percent growth,” said Jesse Cohen, an analyst at Investing.com, a financial markets platform, though he added that the business was doing well.

Even as growth slowed, Facebook managed to wring more marketing dollars from the millions of advertisers who rely on its service, indicating that it has shrugged off some of the regulatory concerns and competitive pressure that have plagued it in recent years.

“We had a good quarter and a strong end to the year as our community and business continue to grow,” said Mark Zuckerberg, Facebook’s founder and chief executive. “We remain focused on building services that help people stay connected to those they care about.”

Profits surged even as Facebook increased its spending on security, research and development, and other areas of the business. Its expenses rose to more than $12 billion in the fourth quarter, up 34 percent from a year earlier. The company also took a charge for settling a class-action lawsuit concerning its biometric data collection, agreeing to pay $550 million to the plaintiffs.

Mr. Zuckerberg is set to focus this year on securing the platform in the run-up to the November election, aiming to avoid being caught off guard with disinformation and foreign interference as the company was in 2016. Election security teams have ballooned at Facebook, which is spending billions of dollars on the effort.