Walmart Inc on Tuesday forecast a smaller drop in full-year profit than previously projected, after deep discounts to clear excess merchandise and a drop in fuel prices helped it beat expectations for quarterly sales.

The retailer spooked markets across the globe last month when it slashed its profit forecast and warned that consumers were pulling back on discretionary purchases at a far greater pace than feared as higher prices for everything from toothpaste to gas hampered their spending power.

That forced Walmart to make steep price cuts on items such as apparel to try to reduce more than $61 billion worth of inventory it was sitting on at the end of the first quarter.

Walmart reported inventories of $59.92 billion at the end of the second quarter ended July 31 that was still 25% above last year's levels.

"The actions we've taken to improve inventory levels in the U.S., along with a heavier mix of sales in grocery put pressure on profit margin for Q2 and our outlook for the year," Walmart Chief Executive Officer Doug McMillon said.

Still, Walmart lifted its fiscal 2023 adjusted earnings forecast less than a month after slashing it. The company now expects adjusted earnings per share to fall 9% to 11%, compared with its previous forecast of a 11% to 13% decline.

Walmart's total revenue rose 8.4% to $152.86 billion in the second quarter, helped by demand for food and other essential items. Analysts had estimated revenue of $150.81 billion, according to IBES data from Refinitiv.

However, discounts on discretionary products, slowing demand for high-margin items such as appliances, electronics and clothes, and rising labor costs led to a 6.8% fall in the company's quarterly operating income to $6.85 billion. (Reporting by Uday Sampath in Bengaluru and Siddharth Cavale in New York; Editing by Anil D'Silva)