H&M Hennes & Mauritz AB (HNNMY)  posted stronger-than-expected second quarter profit Thursday and said it will continue to focus on its digital expansion into the second half of the year even as June sales appear modestly weaker.

The world's second-largest clothing retailer said pretax profit for the three months ending in May rose 10%, well ahead of the market consensus of a 1.6% gain, to SEK7.71 billion ($904.3 million), thanks in part to cost cutting and online sales expansion. 

"Sales in the UK, Scandinavia and Eastern Europe as well as in many of our growth markets were good," said CEO Karl-Johan Persson. "However, it was more challenging in several of our major markets such as the US, China, the Netherlands and Switzerland."

"H&M's online sales developed very well and continued to increase its share of total sales," he added. "The development of COS, & Other Stories, Monki, Weekday and H&M Home remained very strong, both in stores and online."

Earlier this month, H&M said overall sales for its second quarter increased 5% on a local currency basis and grew by 10% once converted into Swedish kroner, to SEK59.538 billion ($6.84 billion). However, its May sales figures missed analysts' forecasts, rising only 4% on a local currency basis against a 6% expectation and its June sales look set to rise 7% against analysts' forecasts of an 8% gain.

H&M shares gained more than 3.5% at the opening bell in Stockholm to change hands at SEK212 each, trimming the year-to-date decline to around 16%, before paring that gain to around SEK207.1 each by mid-day. That contrasts sharply to Inditex SA (IDEXY) , the world's biggest clothing retailer and its main European rival, which has gained more than 6% so far this year and was marked 0.58% lower at €34.33 Thursday in Madrid.