Walmart raised its full-year forecast and reported better-than-expected quarterly results on Thursday, betting that easing inflation will drive stronger sales of groceries and non-essential merchandise like clothing and electronics, sending its shares to a record high in their biggest one-day gain in four years.

Some U.S. retailers in recent weeks have fanned concerns that consumer spending is waning, but behemoth Walmart is not one of them.

The largest U.S. retailer sounded uniformly positive in its outlook Thursday - sending shares up 7% to an all-time high of $64.22. The rally was the sharpest single-day gain for Walmart's stock since March 2020, and it helped lift the Dow industrials past 40,000 for the first time.

U.S. consumer prices rose less than expected in April, but domestic demand has shown signs of cooling as Americans struggle with higher rents, gas prices and car insurance premiums. In the 12 months through April, the consumer price index was up 3.4%, according to Bureau of Labor Statistics data released on Wednesday, though far below the 9.1% pace hit in June 2022.

"These are not inflation-driven results," Walmart CEO Doug McMillon said on a post-earnings call.

Results were driven by more visits to stores and the website by wealthier shoppers and the price gaps it is maintaining against rivals, McMillon said.

In Thursday's report, Walmart said total U.S. comparable sales rose 3.9%, excluding fuel, in its first quarter ended April 30. The average bill at the cash register was flat but the number of transactions rose. Analysts expected those sales to rise 3.15%, according to LSEG.

Online sales in the United States surged 22%, surpassing the 17% growth Walmart posted during the typically robust holiday season.

Growth was driven by Walmart's pickup & delivery services and increased sales of items like men's, women's and children's apparel through its third-party marketplace, which now offers more than 420 million items of mostly discretionary products. Walmart attributed much of the online gains to households earning more than $100,000 per year.

While Americans have generally managed to navigate through higher prices, prolonged inflation has sparked worries that lower-income consumers might be more pressured and potentially slow down an anticipated recovery in spending.

Walmart executives said that lower-income consumers maintained their spending habits in the quarter but tended to prioritize less-expensive items. They also noted that the price gap between eating at home and dining outside had increased, boosting its grocery business, which accounts for about 60% of total revenues.

A 45% increase in the number of food and consumables items it offered on discounts, which it calls rollbacks, in April resonated strongly with shoppers.

"As we continue to work closely with our suppliers to lower cost, we're managing our ... competitive price gaps and customers are responding favorably, resulting in sustained sales growth and higher gross margins," Walmart's finance chief John David Rainey said.

Gross margins rose about 0.4%, helped by newer business such as advertising and Walmart+ membership, Rainey said.

Telsey Advisory analyst Joseph Feldman said Walmart's strong results could bode poorly for the rest of retail as its performance indicates it is taking market share. Target reports results on May 22.

The retailer reported first-quarter adjusted earnings of 60 cents per share, easily beating the 52-cent average forecast. Total revenue of $161.51 billion also topped estimates.

For its fiscal year ending January 2025, Walmart expects sales to rise at the high end or slightly above its prior forecast of 3% to 4% growth, and adjusted profit per share to be at the high end or slightly above its prior estimate of $2.23 to $2.37.

(Reporting by Ananya Mariam Rajesh in Bengaluru and Siddharth Cavale in New York Editing by Nick Zieminski and Will Dunham)