By Sarah Nassauer

Walmart Inc. 's quarterly sales surged as the retail behemoth continued to use its scale, e-commerce supply chain and grocery business to attract shoppers buying food and household goods during the coronavirus pandemic.

Comparable U.S. sales, those at stores or digital channels operating for at least 12 months, rose 9.3% in the quarter ended July 31. It marks the second consecutive quarter of strong growth and evidence that the world's largest retailer is drawing more shoppers as many retailers close stores or declare bankruptcy amid coronavirus struggles.

In the April quarter Walmart's comparable U.S. sales grew 10% and Wall Street was expecting growth of 5.9% for the July quarter, according to estimates compiled by FactSet.

The company's stock rose 3% in premarket trading, hitting an all-time high of $139 a share.

U.S. traffic fell 14% in the July quarter, while the average amount spent per transaction jumped 27%. In the U.S. "customers continued to consolidate store shopping trips," spending more per trip, the company said in a release, "and shifted more purchases to e-commerce." The company's e-commerce business nearly doubled, jumping 97% from a year ago, boosted by people ordering groceries online to pickup in store parking lots.

Walmart said sales were boosted by government stimulus spending, which lifted demand for general merchandise such as electronics, patio furniture, sporting goods and even apparel, a category with weak sales at the start of the pandemic. As the government funds tapered off, sales started to return to more normal levels in the month of July, the company said.

Overall, Walmart reported its global revenue rose 5.6% to $137.7 billion, with gains in most of the countries where it operates. The company spent $1.2 billion on Covid-related expenses for workers and cleaning but still increased profits. Operating profits rose 8.5% to $6.1 billion in the quarter.

Net income was $6.48 billion, compared with $3.61 billion a year ago. The latest period included a large investment gain.

Write to Sarah Nassauer at sarah.nassauer@wsj.com