Refining stocks have been under pressure this year. Weaker demand, higher oil prices, and an increase in facility maintenance activities are among the many issues that have weighed on refining margins and negatively impacted sector profitability. Among the hardest hit has been independent refining giant Marathon Petroleum (MPC -1.30%). That's evident by the surprise loss of $0.09 per share it posted during the first quarter, which missed the analysts' consensus estimate by $0.27 per share.

Analysts, however, believe that the worst of the refining sector's challenges are in the past. That's why they're in near-universal agreement that Marathon's stock -- which has lost almost a third of its value in the past year -- is a buy. Overall, 17 of the 18 firms that cover the refining company now have a buy or equivalent rating on its stock. Here's why they're so bullish on what lies ahead.

A storage tank with the sun rising in the background.

Image source: Getty Images.

Margins have come roaring back

The main issue weighing on Marathon Petroleum's earnings during the first quarter was weaker refining margins. The company only made $11.17 per barrel during the period. That fell well short of analysts' expectations, with Credit Suisse, for example, anticipating that it would earn $13.85 per barrel during the quarter. Those weaker margins were due to the continued challenges facing the refining market, including sluggish demand and higher costs for crude oil.

However, many of the issues facing the sector seem to be fading. Marathon CEO Gary Heminger noted in the company's first-quarter earnings release that "throughout the quarter, refining fundamentals improved [and] gasoline and distillate inventories rebalanced." As a result, margins had increased to $18.80 per barrel by April. That leads Marathon's CEO to "expect positive dynamics across all three of our business segments to support growing cash flows throughout the remainder of 2019."

Even better days appear to be up ahead

Analysts who follow the refining sector agree with Heminger that industry fundamentals are on the upswing. For example, Goldman Sachs, which already had Marathon on its Conviction Buy List, put out a bullish report on the refining sector earlier this month. The investment bank said that it sees the sell-off in high-quality U.S. refiners as a buying opportunity. That's because these companies should benefit from the increased flow of low-cost crude oil to the U.S. Gulf Coast as new pipelines enter service later this year. One of those pipelines is the Gray Oak system, which Marathon is building with some partners to ship oil from the Permian Basin.

That report followed a similar one in late April by Bank of America, which thought that the worst had passed for U.S. independent refiners. This outlook led the bank to upgrade several refiners while reiterating its view that Marathon Petroleum is one of its top-rated ideas in the group.

Another catalyst for Marathon and its refining peers is an upcoming change in global fuel standards, which will go into effect on Jan. 1, 2020. The rule says that oceangoing shipping vessels must use fuels with lower sulfur content, which could spur demand for an extra 12 billion to 30 billion gallons of low-sulfur fuel per year. This rule change will benefit Marathon Petroleum in particular since it has a greater ability than most other refiners to produce higher-value products like low-sulfur fuel due to the complexity level of its refineries. On top of that, the company plans to spend $1.2 billion to upgrade its Galveston Bay refinery so that it can produce even higher quantities of low-sulfur fuels.

Meanwhile, Marathon should also benefit from its recent consolidation moves. The company acquired fellow refiner Andeavor last year, which created the largest independent refiner in the country. One of the driving factors of that merger was the expected cost savings, which should reach an annualized $600 million by the end of this year and $1.4 billion by the end of 2021. On top of that, it recently agreed to combine its two master limited partnerships in a transaction that should reduce costs and enhance its midstream growth prospects. Analysts at Cowen are particularly bullish on the MLP merger. They believe it "can likely unlock $2 billion [of] value net to MPC that is being discounted by the market due to the overhang of this combination and concerns around future growth."

Catalyst-driven upside

While the past year has been challenging for refiners like Marathon, analysts believe that those issues will begin to fade over the next few months. On top of that, Marathon is not only well positioned to benefit from the new fuel standards, but its recent consolidation moves should pay some incremental dividends. This growing list of near-term catalysts leads analysts to believe that Marathon's stock has significant upside potential in the coming year, which is why nearly all of them rate it a buy.