Walmart posted a loss in the third quarter after a settlement resolving claims that it contributed to the nationwide opioid crisis.
Walmart posted a loss in the third quarter after a settlement resolving claims that it contributed to the nationwide opioid crisis. AFP

US retail giant Walmart posted a $1.8 billion loss in the third quarter after a settlement resolving allegations on opioid cases, but lifted its full-year outlook on strong quarterly results.

The big-box retailer, which has been contending with a dimmer profit environment this year as surging inflation squeezed households, said Tuesday that it "continued to gain market share" in the grocery segment, as revenues topped expectations.

But its numbers were bogged down by a settlement set to provide $3.1 billion to communities nationwide and "require significant improvements in how Walmart's pharmacies handle opioids," according to a statement by New York Attorney General Letitia James's office.

This comes as the opioid crisis in the United States -- causing more than 500,000 deaths over 20 years -- triggered a flurry of lawsuits against drugmakers, distributors and pharmacies.

US pharmacy chains CVS Health and Walgreens similarly reached preliminary agreements this month to pay more than a total of $10 billion to resolve opioid claims.

"Pharmacies such as Walmart played an undeniable role in perpetuating opioids' destruction," said James, adding that the settlement is being sent to other states for review and approval.

In a separate statement, Walmart said that it "strongly disputes" the allegations but believes the settlement will help communities in the fight against the crisis.

Walmart reported its third quarter results on Tuesday, announcing revenues of $152.8 billion, up 8.7 percent from a year ago and exceeding expectations.

It expects its full-year adjusted profit will decline between 6.5 percent and 7.5 percent -- an improvement from earlier estimates as well.

"Walmart US continued to gain market share in grocery, helped by unit growth in our food business," said Walmart Chief Executive Doug McMillon in a statement.

He added that the company had a "good quarter with strong top-line growth globally" and that it has improved its inventory position, continuing to make progress towards the end of the year.

"When consumer finances get tough, Walmart gets going. That is the central message from today's strong set of numbers," said GlobalData managing director Neil Saunders in an analysis.

He noted that most of the company's expansion is occurring in grocery where shoppers are feeling the pinch.

Although some of this is down to inflation, "there has also been volume growth which reflects the increase in customer numbers."

Investors have been eyeing the company's results as a proxy for consumer demand.

With US inflation hovering near a decades-high level, consumers have been spending more on staples and pulling back on discretionary items, forcing Walmart to cut its profit outlook in July.

The company also announced in recent months that it would hire 40,000 workers for the upcoming holiday season, significantly lower than before.