Google parent Alphabet's quarterly revenue and profit surged to record highs, powered by a rise in advertising spending as more consumers shopped online.

Shares of Alphabet, the world's largest provider of search and video ads, rose 3.3% in extended trading after the results, which handily beat analyst estimates. Shares of Facebook, which competes with Google in web ad sales and reports its own results on Wednesday, rose 1.3%.

Overall, it was a stellar day for the big US tech companies - Apple and Microsoft also reported record earnings.

With consumers spending more time online during the coronavirus pandemic, retailers have been pushing to reach them there, whether they're shopping for products using Google search or watching videos on YouTube.

The nascent US economic rebound that's accompanied the vaccine rollout and the easing of restrictions is also helping as consumers are enjoying increased mobility and options for purchases of all kinds.

"Alphabet has benefited from the general return of ad spend to the market and especially the balance of that return, which is more focused on digital channels than pre-pandemic," said Tom Johnson, chief digital officer at WPP Mindshare.

Alphabet said revenue from Google advertising rose nearly 70% to $50.44 billion during the second quarter ended June 30.

Retail brands were the biggest contributor to the ads business' growth, said Philipp Schindler, Google's chief business officer, during a call with analysts.

The travel, financial services and media and entertainment sectors were also strong, he added.

Ad revenue for the company's streaming video platform YouTube jumped 83.7% from the year-ago quarter to $7 billion - nearly as much as Netflix generated in quarterly revenue.

Results "outperformed our expectations across all three lines of Google's ad business: search, Google Network, and YouTube," said Nicole Perrin, eMarketer principal analyst at Insider Intelligence.

"YouTube was the fastest-growing segment during the quarter and points to the continued strength of video advertising for both direct response and brand goals."

Total revenue for Alphabet rose 61.6% to $61.88 billion, well above Wall Street estimates of $56.16 billion, according to IBES data from Refinitiv.

Quarterly profit was $18.5 billion or $27.26 per share, beating expectations of $19.34 per share.

Google Cloud, which trails Amazon.com and Microsoft in market share, narrowed its operating loss to $591 million during the quarter.

The strong results coincide with Alphabet facing four antitrust lawsuits brought by U.S. federal regulators or states, which threaten to force major changes across its business including advertising and smart-home gadgets.

Most recently, 37 US state and district attorneys general alleged earlier this month that Google "unlawfully" maintained a monopoly for its app store on Android phones.

The lawsuits are expected to take years to resolve.