Facebook reported a much-higher quarterly profit, driven by surging sales of mobile video ads, as its advertising revenue grew at more than twice the rate of larger rival Google.
The company also said on a conference call to discuss the results that 2017 expenses would rise less than previously forecast -- it's now saying that expenses will go up 40 to 45 percent, instead of 40 to 50 percent.
The stock jumped as much as 4 percent to a record high after Facebook announced that news.
Here are the key second-quarter metrics:
Facebook has been adding more video and display ads to the mobile version of its app as more consumers access the internet via their smartphones. The company is expected to add short TV-like programming soon.
"We are making some early investments to create episodic content," Facebook Chief Operating Officer Sheryl Sandberg told CNBC in an interview.
The company has also overhauled its Instagram service over the past year to beat back a challenge from smaller rival Snap.
More than 15 million businesses now have a presence on Instagram, in addition to the 70 million who have Pages on Facebook, Sandberg said.
"Our goal is to be a platform for content creators," she said.
Mobile ad sales now provide most of Facebook's revenue and hit $8 billion for the quarter, a jump of 53 percent and more than analysts expected.
"As content consumption changes, online marketers are saying, 'I want to reach consumers wherever they are, whatever device they're using," said David Staas, president of NinthDecimal, which provides location data and other digital marketing tools to 250 ad agencies, brand advertisers and media companies.
"Facebook is well-positioned" to take advantage of the trend, Staas told CNBC in a phone interview.
The market for digital video (not including traditional TV ads) is projected to rise 19 percent this year to $11.7 billion, according to data from the research firm eMarketer, cited in a May report from the Interactive Advertising Bureau.
The average price of an ad rose 24 percent, Chief Financial Officer David Wehner said on a conference call with analysts after the results were released.
The number of ads rose 19 percent, Wehner said.
Capital expenditures were $1.44 billion, up 45 percent but less than expected, the company said in its report.
Facebook is building more data centers to handle the surge in video traffic on its websites and is also on a hiring spree.
The company now has 20,658 workers, up 43 percent from a year earlier.
"We remain very solidly in investment mode," Sandberg told CNBC.