OAKLAND, Calif. — A day after lawmakers grilled the chief executives of the biggest tech companies about their size and power, Amazon, Apple, Alphabet and Facebook reported surprisingly healthy quarterly financial results, defying one of the worst economic downturns on record.

Even though the companies felt some sting from the spending slowdown, they demonstrated, as critics have argued, that they are operating on a different playing field from the rest of the economy.

Amazon’s sales were up 40% from a year ago, and its profit doubled. Facebook’s profit jumped 98%. Even though the pandemic shuttered many of its stores, Apple increased sales of all its products in every part of the world and posted $11.25 billion in profit. Advertising revenue dropped for Alphabet, the laggard of the bunch, but it still did better than Wall Street had expected.

“The strong continue to get stronger,” said Dan Ives, managing director of equity research at Wedbush Securities. “As many companies are falling by the wayside, the tech stalwarts continue to gain muscle and power in this environment.”

The tech companies’ financial performance was a remarkable contrast to the overall health of the U.S. economy. The Commerce Department said Thursday that the country’s gross domestic product fell 9.5% in the second quarter of the year as consumers cut back spending. It was the steepest drop on record.

Combined, the companies reported $28.6 billion in quarterly net profit, underscoring how regulatory scrutiny remains more background noise and a distraction for them than an imminent threat to their businesses.

Advertising

On Wednesday, a congressional antitrust panel questioned the companies’ leaders — Jeff Bezos of Amazon, Tim Cook of Apple, Mark Zuckerberg of Facebook and Sundar Pichai of Alphabet — about their market power and business practices.

The pandemic has reinforced the advantages held by the big tech companies. As consumers stay home, demand for Amazon’s shopping site surged, while companies are turning to its cloud computing products to keep their services up and running. Apple said the shift to working and learning from home had led more people to splurge on Apple’s devices and use its services.

Facebook and Google continue to be important to marketers, and they are weathering the downturn in advertising better than rivals.

Since the beginning of March, the companies’ stock prices have risen by an average of 35%, compared with a 10% rise in the S&P 500.

Amazon

Buoyed by a pandemic-induced surge in online shopping, Amazon had $88.9 billion in quarterly sales, up 40% from a year earlier. Profit doubled, to $5.2 billion, even though the company invested in expanding warehouses and other ways to increase capacity. Earnings were $10.30 a share, beating analysts’ average projection of $1.51 per share on sales of $81.2 billion, according to data compiled by Bloomberg

“Simply put, COVID-19, in our view, has injected Amazon with a growth hormone,” Tom Forte, an analyst at the investment bank D.A. Davidson & Co., wrote in a recent note to investors.

Advertising

In April, Bezos told investors to expect no operating profit, and maybe even a loss, as the company planned to spend about $4 billion on coronavirus-related expenses like temporary pay increases, declines in warehouse efficiency because of social distancing, and $300 million for testing its workforce for the virus.

But even those costs did not compare to the immense surge in demand, with online retail sales up 48%.

On a call with reporters, Amazon declined to say if it would give its warehouse workers virus-related bonuses or raises in the current quarter but added that pandemic-related expenses would fall to $2 billion in the quarter.

Sales at Amazon’s lucrative cloud computing business, whose customers include major corporations and small startups, grew 29%, to $10.8 billion, falling short of analyst expectations, although it was more profitable than they had expected.

Amazon’s workforce jumped 34% to 876,800 full- and part-time employees at the end of the quarter. “We’ve created over 175,000 new jobs since March and are in the process of bringing 125,000 of these employees into regular, full-time positions,” Bezos said in a statement.

Amazon expects its momentum will continue. Overall sales in the third quarter will range from $87 billion to $93 billion, which would amount to growth of 24% to 33% from the same period last year, the statement said.

Advertising

Facebook

Facebook’s revenue for the second quarter rose 11% from a year earlier to $18.7 billion, while profits jumped 98% to $5.2 billion. The results were well above analysts’ estimates of $17.3 billion in revenue with a profit of $3.9 billion, according to data provided by FactSet.

Despite increasing scrutiny from regulators, questions about its role in subverting elections and how people use the platform to spread misinformation, neither users nor advertisers have shown an inclination to stop using Facebook.

More than 3 billion people now regularly come to Facebook or one of its family of apps, as the services have overtaken much of the developed world. And some 2.47 billion people use one or more of Facebook’s apps every day.

Apple

Despite the global economic slowdown, people kept buying Apple devices en masse and paid the tech giant billions of dollars more for apps and services on those gadgets.

Apple said its sales rose 11% to $59.7 billion and its profits increased 12% to $11.25 billion. Both figures handily beat analysts’ expectations, with Wall Street having forecast declines in both areas.

Sales were particularly strong for iPads and Mac computers, as the public was increasingly forced to work and socialize virtually. Revenue also surged in its internet-services business, which include Apple’s cut of sales from the App Store, the subject of antitrust investigations in the United States and Europe.

Alphabet

Google’s parent company, Alphabet, reported its first-ever decline in quarterly revenue, hurt by a slowdown in spending by advertisers. The company posted revenue of $38.3 billion and a profit of $6.96 billion — significantly higher than what Wall Street analysts had predicted.

Ruth Porat, Alphabet’s chief financial officer, said advertising revenue “gradually improved” as the quarter went on. The decline came largely from lower sales of advertisements that run alongside Google’s search results, but the company’s efforts to diversify its business paid off as revenue from YouTube ads and its cloud computing business grew.

Seattle Times business staff contributed to this report.