The Swedish company, which has seen profit fall in the past two years as fewer customers shop in its main H&M brand stores, said it would now be tougher to reach its target of a "somewhat better" group result for the year.

Pretax profit in the three months to the end of May shrank 22 percent from a year ago to 6.01 billion crowns (511.80 million pounds), slightly below the average forecast in a Reuters poll of analysts.

"The first half of the year has been somewhat more challenging than we initially thought, but we believe that there is a gradual improvement and that we will see a stronger second half," Chief Executive Karl-Johan Persson said on Thursday.

H&M shares fell 4 percent at the opening but turned positive to trade 0.3 percent higher by 0758 GMT.

After decades of rapid expansion growing to more than 4,700 stores, the world's second-largest clothes retailer behind Zara owner Inditex has seen sales growth stall as it has struggled to adapt to the shift online and fend off increased competition from other budget brands.

It has also been less successful than Inditex, which sources production close to its headquarters in Galicia, northern Spain, in responding to fast-changing fashions.

H&M said earlier in June that sales in the March-May quarter were unchanged, after shrinking in the previous two quarters.

The group's inventories and markdowns have been gradually increasing in the past couple of years. As expected by analysts, they grew again in the second quarter to the end of May -- inventories by 13 percent and markdowns by 1 percent.

In comparison, Inditex has reported healthy local-currency sales growth for its February-April quarter as well as for the following six weeks.

Analyst Richard Chamberlain of RBC Capital Markets noted the pressure on margins from sluggish sales.

"We are also concerned that H&M is over-distributing and may be forced to cut its dividend this year or next if sales trends remain sluggish," Chamberlain, who has an "Underperform" rating on the stock, said in a note.

H&M shares have lost nearly two thirds of their value since record highs in 2015, underperforming Inditex which have performed better helped by a more flexible supply chain and earlier integration of online and stores with services such as click-and-collect.

The stock has in recent months gyrated amid large stock purchases by the founding Persson family, rumours of buyout plans prompted by the purchases, and a subsequent dismissal this month of the rumours by Chairman Stefan Persson.

H&M said work to speed up its logistics systems had resulted in temporary interruptions in the quarter, hitting sales in some major markets such as Germany and the United States.

The company has earlier guided for lower comparable-store sales in 2018 than in 2017, with a gradual improvement throughout the year.

(Additional reporting by Helena Soderpalm; Writing by Keith Weir; Editing by Georgina Prodhan)

By Anna Ringstrom