By Rob Copeland

The global pandemic dealt a rare losing hand to Google's venerable digital advertising operation, pushing quarterly revenue down compared with a year earlier for the first time in company history.

The search-engine giant posted a $2.6 billion, or 8%, drop in advertising for the second-quarter from a year earlier, as some of Google's biggest advertisers, including travel companies and consumer brands, cut back on spending amid economic uncertainty.

(Facebook, Amazon and Apple also reported earnings on Thursday. Follow our coverage for results and analysis.)

In all, Google's parent, Alphabet Inc., reported advertising revenue of $29.9 billion for the three months through June. That metric, which includes ads on Google's own properties as well as those placed on other websites, fell short of the $32.5 billion haul a year earlier. The weakness appeared to have been driven mostly by Google's traditional venues such as search; the YouTube video unit, for instance, posted a modest rise in revenue.

Google's advertising revenue had risen every quarter of the company's 22-year history, so the reversal is notable. Analysts polled by FactSet had expected the drop in advertising revenue, and investors were mostly undisturbed. Alphabet shares rose about 1% in after-hours trading.

Alphabet Chief Executive Sundar Pichai blamed the macroeconomic environment caused by the coronavirus pandemic, and said he saw early signs of potential stabilization. The conglomerate reported total profit of $6.4 billion, a 30% drop from a year earlier. Alphabet's margin was crimped as well, down to 17%, from 24% a year earlier.

The malaise ate into Alphabet's enviable cash hoard. Alphabet has modestly drawn down what was an $18.5 billion cash position in January. It now stands at $17.7 billion.

On the regular call with analysts, executives said advertising had steadily improved throughout the quarter. They were loath, however, to proclaim victory. "We do believe it's premature to say we are out of the woods," said Chief Financial Officer Ruth Porat.

The pandemic seems to have landed harder at Google than at some of its Big Tech peers. A few minutes before Google disclosed its figures, Amazon.com Inc. said its sales and profit soared in the second quarter as shoppers inundated the company's site with orders and employees worked from home. And while Facebook Inc. posted diminished growth for the second quarter, the stock surged as revenue came in higher than expected and the social-media giant benefited from higher engagement from users amid the pandemic.

Google has more immediate pressures than its neighbors, too. The company, based in Mountain View, Calif., faces multiple antitrust investigations into whether its dominant business harms consumers. The company broadly denies that. U.S. prosecutors are expected to file charges against the company as soon as this summer, The Wall Street Journal has reported.

Mr. Pichai was among executives to testify remotely for Congress on Wednesday, where he faced questions about whether the search platform had cut off traffic to potential competitors. "The scrutiny is going to be here for a while," he said Thursday.

The company continues to hammer into new markets, including cloud computing, which posted a 43% rise in revenue and merited several mentions in Mr. Pichai's remarks. That growth is slower than the cloud businesses at some of Google's larger peers. Microsoft Corp.'s cloud division Azure -- more than four times the size of Google's by revenue -- grew 47% in the most recent quarter, the company said last week.

Google boasts roughly 200,000 full-time and contract employees, including thousands added this year. Mr. Pichai said earlier this week that most employees, including those in the U.S., would be instructed to work from home until at least next summer. On Thursday's earnings call, executives nodded to that decision, saying the company would slow purchases of new offices.

Ms. Porat said the company remained in the process of "reimagining the optimal work environment."

Write to Rob Copeland at rob.copeland@wsj.com