* Shares up 56% so far this year but still half 2015 peak
* June to August pretax profit edges above forecasts
* Operating margin reaches 8.0% against 7.7% consensus
* H&M battling to reverse years of slowing high street sales (Adds analyst comment, share opening)
STOCKHOLM, Oct 3 (Reuters) - H&M, the world's second-biggest fashion retailer, reported on Thursday its first quarterly rise in pretax profit in more than two years and said efforts to meet rapid changes in the market were on track.
H&M has been spending heavily on reviving its business after years of falling profits and growing inventories due to slowing sales at its core H&M branded stores, which have faced tougher competition and grappled with the shift to more online shopping.
Its shares rose 6.8% in early trade. They have now spiked 56% so far this year and more than 60% from the 13-year low seen in 2018 but remain about half their 2015 record level.
"H&M delivered its first strong quarterly earnings in over four years, which could raise confidence in the turnaround," investment bank Carnegie said in research note.
Pretax profit in the period from June to August beat expectations, growing to 5.0 billion crowns ($507 million) from a year-ago 4.01 billion crowns. Analysts had on average forecast a rise to 4.93 billion crowns, according to Refinitiv data.
The increase was the Swedish group's first since the second quarter of 2017. Profit growth was helped by accelerating growth in sales on the back of strong demand for summer collections and gains in market share.
"The continued development of more full-price sales and reduced markdowns contributed to a 26% increase in operating profit in the third quarter, all while maintaining a high level of activity in our transformation work," CEO Karl-Johan Persson said in a statement.
The gross margin widened to 50.8% from 50.3%, and the operating profit margin to 8.0% from 7.1%.
"Overall this is a solid set of results ... driven by the gross margin coming in 40 basis points ahead of expectations due to a stronger than expected markdown improvement," JP Morgan analysts said in a note.
Inventories increased 9% to 42.0 billion crowns at the end of the third quarter, equivalent to 18.5% of sales. However, H&M said that, measured in local currencies, they shrank by 1% while the composition of the stock had kept improving.
Markdowns decreased for a fourth straight quarter, by 2 percentage point in relation to sales. H&M had in June predicted a 1.5 percentage point decrease. The company broke a habit by not providing an outlook for markdowns in the current quarter.
H&M said sales in September, the first month of its fourth quarter, grew 8% in local currencies.
($1 = 9.8736 Swedish crowns) (Reporting by Anna Ringstrom; Additional reporting by Johannes Hellstrom; Editing by Niklas Pollard and Edmund Blair)