By Uday Sampath Kumar and Siddharth Cavale

(Reuters) -Walmart Inc nudged up its annual profit forecast on Tuesday, partly reversing a hefty cut less than a month ago, as discounts to clear excess merchandise and lower fuel prices helped it beat expectations for quarterly sales.

The stock, which has fallen over 8% this year, rose 4% in premarket trading. Shares of rivals Target Corp, Costco and Best Buy also climbed on the news, while futures for the blue-chip Dow index cut losses.

Walmart said it now expected fiscal 2023 adjusted earnings per share to fall 9-11%.

Last month, the top U.S. retailer spooked markets across the globe when it forecast a drop of 11-13% – down from previous guidance for a 1% fall – and warned consumers were pulling back on discretionary purchases at a far greater pace than feared as soaring inflation hit 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.

A host of other retailers including Target Corp and Best Buy Co Inc have also issued profit warnings in recent weeks as they struggle with excess merchandise.

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

“I think it’s going to take another quarter, maybe get into the fourth quarter a little bit, to get back to where we want to be from an overall inventory perspective,” Walmart’s Chief Financial Officer John David Rainey said.

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.

Since the last round of quarterly results, the prices consumers pay for goods and services have shown signs of easing. The consumer price index rose 8.5% in July, less than in the previous month, due largely to a 17% drop in gasoline prices.

Sales at Walmart’s U.S. stores open for at least a year, rose 6.5%, in part due to higher prices and an easing of fuel inflation, and beat its prior forecast for a 6% gain.

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.

The Bentonville, Arkansas-based retailer now expects consolidated net sales growth of about 5% and adjusted earnings to decline 9.0% to 11.0% in the third quarter. Same-store sales for Walmart U.S., excluding fuel, are expected to rise 3%, the company said.

Home Depot Inc on Tuesday also reported strong quarterly sales for the second quarter helped by steady demand for home-improvement goods from builders and handymen.

(Reporting by Uday Sampath in Bengaluru and Siddharth Cavale in New York; Additional reporting by Arriana Mclymore; Editing by Anil D’Silva and Mark Potter)