U.S. refining company Marathon Petroleum Corp (MRO) posted a lower-than-expected quarterly profit on Thursday, hurt by shrinking crude discounts and weakness in products markets.

Marathon, the third-largest stand-alone U.S. refining company, reported third-quarter net income of $168 million, or 54 cents per share, compared with $1.22 billion, or $3.59 per share, in the year-ago quarter.

Excluding pension expenses and other one-time items, Marathon earned 59 cents per share.

By that measure, analysts expected earnings of 61 cents per share, according to Thomson Reuters I/B/E/S.

Some Wall Street analysts had expected the miss to be bigger -- one top analyst at Barclays forecast the company would report earnings of nil per share -- and shares rose 2 percent to $73.71 in morning trading.

During the quarter the difference between the price of West Texas Intermediate crude oil and Light Louisiana Sweet crude oil shrunk 76 percent from the year-ago quarter, wiping out much of a big cost advantage and squeezing margins.

Refiners make more money when the price difference between various types of crude oil is wide. When the gap narrows, costs tend to rise, eroding profit.

Total revenue rose 24 percent to $26.27 billion. Analysts expected revenue of $21.37 billion.

Shares of the Findlay, Ohio-based have gained nearly 18 percent so far this year.