H&M has posted its first rise in quarterly profits for more than two years as digital investments and strong demand for its summer collections bore fruit.

The Swedish fashion giant said pre-tax profit jumped 25% to 5bn krona (£413m) in the three months to August. It outstripped analysts’ expectations, which had forecast quarterly earnings of 4.9bn krona, and marked its first quarterly profit increase since the second quarter of 2017.

Net sales grew 12% during H&M’s third quarter to 62.57bn krona (£5.14bn), buoyed by a 30% spike in online sales.

Operating profit margin climbed to 8% from 7.1% during the same period a year ago.

H&M is in the midst of a digital transformation, ploughing cash into sharpening its online presence. The retailer is also working to slash inventory levels and cut back on discounting.

The amount it sold on promotions decreased two percentage points, marking the fourth consecutive quarter of decline. However, it did not forecast what markdowns would be in its current quarter.

Its ongoing transformation efforts have driven a 46% uplift in its share price so far this year, but it is still languishing at half of the record levels reached back in 2015.

H&M chief executive Karl-Johan Persson said: “Well-received summer collections and increased market share show that we are on the right track with our transformation work to meet customers’ ever-increasing expectations.”