By Dominic Chopping

STOCKHOLM -- Hennes & Mauritz AB said its recovery from the coronavirus-led slump in retail had been better than expected, prompting shares in the fashion retailer to soar 12%.

The Swedish company said Tuesday that well-received collections, more full-price sales and its speedy response to Covid-19 had helped it return to profit in the three months to Aug. 31 after a heavy loss in the previous quarter.

H&M, like other retailers, was forced to temporarily shut stores in many of its key markets as coronavirus lockdowns came into force, while demand for its garments was also hurt by uncertainty related to the pandemic. In response, the company adjusted product-purchasing plans, cut costs for staffing and real estate, and put more emphasis on online sales.

Those efforts, combined with the gradual reopening of stores, appear to have paid off in recent months. H&M said preliminary results showed a profit before tax of approximately 2 billion Swedish kronor, equivalent to $228 million, in its fiscal third quarter. That is down from 5.01 billion kronor in the same period last year but far better than the 396 million kronor profit expected by analysts. Sales in the quarter fell 19% to 50.87 billion kronor.

The figures represent an improvement on the company's performance in the second quarter, when it reported a 6.48 billion kronor loss on sales down 50%.

H&M, which also owns the Cos brand, said more of its stores had reopened in recent weeks. At the beginning of the quarter approximately 900 of its more than 5,000 stores were temporarily closed, but at the end of the quarter just above 200 stores were still shut. In the middle of April, around 80% of the group's stores were temporarily closed.

Analysts welcomed the company's latest figures but cautioned that the overall retail environment was still subdued. For instance, analysts at Citi said they were looking for a material improvement at H&M in the fourth quarter but had to balance the company's robust trajectory with a market still down 10% to 15% in many key countries.

Write to Dominic Chopping at dominic.chopping@wsj.com