The social network said that mobile ads accounted for 41 percent of it’s total advertising revenue. (Ben Margot/AP)

Facebook’s stock is flying high after the world’s biggest social network posted higher revenue from mobile ads and delivered a healthy second-quarter profit that reversed a loss in the same period a year ago.

The results, which come on the heels of weaker-than-expected results from online search leader Google, signal that Facebook’s aggressive push into the mobile advertising market continues to pay off. The company began showing mobile ads for the first time last spring. On Wednesday, Facebook said mobile ads accounted for 41 percent of its total advertising revenue.

The Menlo Park, Calif.-based company’s stock jumped $4.48, or 17 percent, to $30.99 in after-hours trading. The shares had closed the regular trading session at $26.51. Facebook’s stock was priced at $38 when the company went public in May 2012, but it hasn’t hit that range since.

“I’m completely surprised,” said Gartner analyst Brian Blau, summing up the sentiments of many investors who have watched Facebook’s stock price stagnate over the past year due in large part to concerns about its mobile prospects.

“I was actually thinking that maybe they would have a soft quarter,” he said, citing a softening of display advertising revenue — Facebook’s bread and butter — across the industry. “That seems not to be the case.”

Facebook said it earned $333 million, or 13 cents per share, in the April-June period. That’s up from a loss of $157 million in the same period a year ago. Adjusted earnings were $488 million, or 19 cents per share, above the 14 cents that analysts were expecting.

Facebook’s revenue grew 53 percent, to $1.81 billion from $1.18 billion, well above the amount that analysts polled by FactSet were expecting. The company also has quickened the pace of its revenue growth. In the first quarter, revenue grew 38 percent and in the fourth quarter of last year, 40 percent.

Mobile ad revenue was $655.6 million, or 41 percent of the quarter’s total advertising revenue of $1.6 billion. In the first quarter, mobile accounted for 30 percent of total ad revenue.

The research firm eMarketer expects Facebook to increase its mobile advertising revenue more than fourfold to over $2 billion this year. This would give the company a 13 percent share of the global mobile ad market, up from about 5 percent last year.

That said, Google is a distant No. 1 when it comes to mobile ads. EMarketer estimates the company held a 52 percent share of the global $8.8 billion mobile ad revenue.

In a conference call with analysts, chief executive Mark Zuckerberg sought to ease concerns that teenagers are growing tired of Facebook and flocking to newer services such as Facebook-owned Instagram. “Based on our data, that isn’t true,” he said.

— Associated Press