Peabody Energy (BTU) said Thursday it swung to a third-quarter loss, but shares of the coal producer rallied 7.2% on a surprise adjusted profit.

The company also provided a better-than-expected outlook for the full year, calling for adjusted per-share earnings of 27 cents to 45 cents. Analysts recently expected 19 cents a share.

St. Louis-based Peabody reported a $26.1 million loss, or 10 cents a share, compared to a year-ago profit of $42.9 million, or 16 cents a share. Excluding discontinued operations and other one-time items, adjusted earnings were five cents a share, below last year’s 53 cents.

Revenue declined 13% to $1.8 billion.

Analysts were looking for an adjusted per-share loss of four cents and revenue of $1.78 billion.

Coal producers like Peabody are facing depressed thermal-coal prices in the U.S. as utilities use significant inventories and shift to cheap natural gas. Peabody has also seen a decline in global prices for metallurgical coal, which is used in steelmaking.

Chairman and CEO Gregory Boyce said the company benefited from cost reductions and higher Australian volumes in the latest period.

Third-quarter operating costs were down about 4.6%.

Peabody shares jumped $1.28 to $19.17 in late morning trading. The stock was down 33% year-to-date through Wednesday’s close.

Follow Matthew Rocco on Twitter @MatthewRocco