Facebook Chief Operating Officer Sheryl Sandberg said in an interview the huge increase in expenses was for "growth we need now and in the future."
"We're investing in the next set of services and what will be future investments like Messenger, WhatsApp and Oculus," she added.
Macquarie Research analyst Ben Schachter said Facebook's costs and spending met expectations. "We think the company has a lot of opportunities ahead of it so we want to see them investing quite heavily in those investments," he said.
Facebook shares fell about 2.5 percent in after-hours trading. As of Wednesday's close of $96.99, the stock has risen 24.3 percent this year, valuing the company at $276.4 billion.
For the quarter, revenue jumped to $4.04 billion from $2.91 billion.
Net income attributable to stockholders fell to $715 million, or 25 cents per share, from $788 million, or 30 cents per share, a year earlier.
Excluding items, the Menlo Park, California-based company earned 50 cents per share. Analysts on average had expected earnings of 47 cents per share on revenue of $3.99 billion, according to Thomson Reuters I/B/E/S.
Advertising revenue grew 43 percent to $3.83 billion. Mobile ads accounted for 76 percent of that, up from 62 percent in the same quarter last year.
Facebook, the world's largest social media network, said it had 1.49 billion monthly active users as of June 30, up 13 percent from a year earlier. Of these, 1.31 billion accessed the service through mobile devices, a rise of 23 percent.
Daily active users increased to 968 million in June, up 17 percent from the same month last year.
"It's particularly impressive that users are more engaged than ever before - that the percentage of monthly users who visit every day continues to grow," said Nate Elliott, an analyst with Forrester Research.