Four years ago, Delta Air Lines (NYSE:DAL) shocked analysts by buying an oil refinery from what soon became Phillips 66 (NYSE:PSX). In the years since then, Delta's new Monroe Energy subsidiary has delivered mixed results. At times, it has posted strong profits, but it has also experienced long periods of breakeven performance -- or worse.

Delta's refinery segment has now entered another period of weak profitability. Fortunately, this isn't actually a bad thing for Delta Air Lines investors.

Delta buys a refinery

When Delta bought the (then-shuttered) Trainer refinery complex from Phillips 66, it paid just $150 million after a $30 million job-creation incentive from the state of Pennsylvania. It then invested about $100 million in the refinery to increase its jet fuel production capability.

Despite this modest initial investment of $250 million, Delta told investors that the refinery would help it reduce its annual fuel expense by $300 million. That's because owning a refinery would allow Delta to avoid the steep markup it was paying on jet fuel (relative to the cost of crude oil).

Losses pile up -- then recede

Initially, Delta's new Monroe Energy segment failed to meet the company's profit expectations. In 2012, the refinery segment posted a full-year loss of $63 million as damage from Superstorm Sandy disrupted operations in November and December.

These problems were resolved within a few months, but a steep drop in crack spreads -- the difference between the cost of crude oil and the price of refined products -- led to an annual loss of $116 million in 2013.

In 2014, crack spreads began to increase again, allowing Delta's refinery to reach profitability. Still, the $96 million full-year profit was significantly less than what the company had advertised to investors. Last year, the refinery came into its own, as the sharp drop in oil prices and rising demand for refined products boosted crack spreads. The refinery posted a full-year profit of $290 million in 2015.

This period of high profitability at the refinery didn't last long, though. The refinery segment lost $28 million last quarter, as crack spreads have collapsed again. For the full year, Delta hopes that the refinery will break even.

The refinery isn't a profit machine -- it's a hedging tool

Looking at the volatile profitability of the Trainer refinery, it's easy to understand why Phillips 66 didn't want to continue operating it. As a pure-play refiner, it makes more sense for the company to stick to operating the most efficient refineries, which generate the highest margins.

However, that doesn't mean that Delta got a bad deal. Delta's rationale for buying the refinery wasn't exactly to earn big profits by refining oil -- it wanted to hedge against the risk of high crack spreads that would drive up the price of jet fuel.

By paying to reopen a refinery that was otherwise slated to close and retooling it to produce more jet fuel, Delta has increased the supply of jet fuel, particularly in the Northeast. All else equal, that would tend to push down refining margins, hurting the refinery's profitability.

But when the refinery loses money because of low crack spreads, Delta simultaneously saves hundreds of millions of dollars through lower jet fuel prices. The fuel cost savings more than offset the refinery losses.

Thus, in today's environment of weak refining margins, refiners like Phillips 66 are expected to report sharp profit declines. Meanwhile, analysts expect Delta's earnings per share to soar more than 40% year over year in 2016. This shows how Delta wins regardless of whether crack spreads are high or low.

Smooth operations are the key

This isn't to say that Delta's refinery gamble has been risk-free. However, tightening crack spreads aren't the big risk, as would be the case for a pure-play refiner like Phillips 66.

Instead, the real risk is that maintenance issues or other operational problems could disrupt the refinery's production (and possibly require costly repairs). In that scenario, Delta could lose money on the refinery while still paying high crack spreads to buy jet fuel for the airline.

So far, the Monroe Energy management team has done a great job of avoiding these snafus. Other than the late 2012 disruptions associated with Superstorm Sandy, there have been no major production problems. As long as it stays that way, Delta's refinery purchase will continue to pay big dividends for investors.