The company has been investing in artificial intelligence technologies, as well as building the immersive world of the metaverse.

For months, Meta and other big technology companies have spent heavily to build artificial intelligence technologies, which show no immediate signs of yielding profits. For months, the companies have also delivered a consistent message about the investments: Trust us.

On Wednesday, Meta, which owns Facebook, Instagram and WhatsApp, showed it was not changing course. The company said it had spent $8.5 billion in the second quarter on computing infrastructure for A.I., building the immersive world of the metaverse and other expenses, up 33.4 percent from a year ago.

Meta also raised part of its spending forecast, saying its expenditures for the year would total $37 billion to $40 billion, up from a prior estimate of $35 billion to $40 billion.

Revenue for the second quarter was $39.1 billion, up 22 percent from a year earlier and above Wall Street estimates of $38.3 billion, according to data compiled by FactSet. Profit was $13.5 billion, up 73 percent from $7.8 billion a year earlier.

Meta also signaled that its ad business remained strong. The company said it expected revenue of $38.5 billion to $41 billion for the current quarter, above Wall Street expectations of $39.3 billion.

Shares of Meta rose 5 percent in after-hours trading, after closing at $474.83.

Meta has continued to grow as its spending has come under increasing scrutiny. After an initial wave of enthusiasm for A.I. when OpenAI’s ChatGPT burst onto the scene in 2022, Wall Street has started to question how much money the technology can generate. Those concerns have been compounded by the billions of dollars that Meta has shoveled into building virtual reality and augmented reality headsets and glasses for the metaverse.

Meta has already cut one A.I. initiative that failed to gain traction — artificially intelligent characters based on Jane Austen, Snoop Dogg, MrBeast, Charli D’Amelio and other famous people that could chat across its messaging apps. The company unveiled the A.I. characters less than a year ago. The Information earlier reported the reversal.

Even so, Mark Zuckerberg, Meta’s chief executive, has bet on A.I. Before raising the annual spending forecast on Wednesday, his company had already upped it in April to $35 billion to $40 billion, up from a previous estimate of $30 billion to $37 billion. The moves are driven by heavy investments in A.I. infrastructure, including data centers; chip designs; and research and development.

Other tech giants have also been spending billions on A.I. Microsoft said on Tuesday that its capital expenses had totaled almost $19 billion last quarter, more than twice as much as two years earlier. Last week, Alphabet said its capital expenditures for the last quarter had surged 91 percent from a year earlier.