By Sarah E. Needleman

Facebook Inc. posted a sharp increase in quarterly revenue and profit as it benefited from a wave of digital ad spending but said it expects growth to slow later this year from factors including Apple Inc.'s new ad-targeting rules.

The social-media giant said Wednesday its first-quarter earnings report reflects the past year's trend of people spending more time and money online and advertisers redirecting their resources to take advantage of that shift. The parent of Facebook, Instagram and WhatsApp said the average price per ad and the number of ads it delivered during the January-through-March period increased.

Advertising revenue -- which accounts for the lion's share of Facebook's total revenue -- rose 46% from a year earlier to $25.44 billion. The company's profit nearly doubled to $9.5 billion, or $3.30 a share.

Shares in the parent of Facebook, Instagram and WhatsApp rose more than 5% in after-hours trading, as both total revenue and profit beat Wall Street forecasts. The stock has gained 16% over the past three months through Wednesday's close, compared with a more than 10% gain in the S&P 500.

The strong results came as Google parent Alphabet Inc. on Tuesday said it shattered sales records for the first quarter and that profit more than doubled. Also Tuesday image-sharing platform Pinterest Inc. said revenue jumped 78% and last week Snap Inc. said its quarterly revenue rose 66% as it gained more Snapchat users. Twitter Inc. is scheduled to release its quarterly financial report Thursday.

Apple and Facebook have butted heads in recent years over issues such as user privacy and app-store fees, and now they are at odds over the iPhone maker's move this week to begin enabling its mobile customers to opt out of letting third-party apps collect certain data. Facebook Chief Executive Mark Zuckerberg has criticized the move, saying it will hurt small businesses. Apple has said it wants app makers to first obtain users' permission to enable such tracking.

In its earnings report, Facebook also said that the strong revenue growth experienced late last year might be tough to repeat. The global advertising business slowed dramatically in the early days of the pandemic, but Facebook as well as other digital platforms rebounded quickly and posted strong revenue and profits in the second half of 2020. As a result of tough financial comparisons and Apple's new rules, the social-networking company said it expects year-over-year revenue growth to slow in the third and fourth quarters.

Facebook Wednesday also pledged to accelerate spending on investments including technical and product talent and consumer hardware. The company has said it is working to enable users to listen to podcasts through Facebook and create Clubhouse-like rooms for live audio conversations. Clubhouse is an audio-discussion app that debuted last year. It last month said it is working on augmented-reality glasses in tandem with sensor-packed wristbands that can detect finger movements.

"What that says is they're aggressive in their pursuit of growth," said Truist Securities analyst Youssef Squali. "They're doubling down on investments."

Write to Sarah E. Needleman at sarah.needleman@wsj.com

(END) Dow Jones Newswires

04-28-21 1723ET