H&M will pay $36m to settle accusations that the fashion retailer illegally kept millions of dollars in gift cards that customers never used, New York Attorney General Letitia James has said.

The Swedish company, whose full name is H&M Hennes & Mauritz, will pay $28.26m to the state and $7.74m to a whistleblower, William French.

James said H&M had since 2008 unlawfully kept at least $18.4m in unused gift card balances in its own bank accounts, instead of transferring them to the state's Abandoned Property Fund.

New York law requires gift card issuers to turn over unused card balances to the fund after five years of inactivity.

James also said H&M repeatedly lied about the missing transfers by saying an Ohio company, which had no obligation to send the balances to New York, handled its gift card business.

"My office has zero tolerance for companies that disregard the law and line their pockets with money that belongs to hardworking people," James said in a statement. "Violating the law is not trendy or tolerable."

H&M, based in Stockholm, did not admit or deny wrongdoing in agreeing to settle.

The company had no comment on the settlement.

H&M has about 4,800 stores worldwide, and posted net sales of 199 billion Swedish krona ($20.1 billion) in 2021.

French had sued H&M in 2016, accusing it of violating New York's False Claims Act.

In a statement, his lawyer Daniel Miller said taxpayers "should be thankful" for his client's efforts.

Customers with unused H&M gift cards issued between 2004 and 2014 can use them at H&M, or file a claim with New York's Office of Unclaimed Funds.