Oil prices have gone on a wild ride so far in 2019. Crude started the year near $45 a barrel before rebounding up above $66 by the end of April. Oil then tumbled into another bear market in May, falling toward $50 a barrel. It has since recovered a bit and was recently above $55.

All that volatility has had a direct impact on oil stocks. One of the more notable moves has been by Marathon Oil (MRO -0.38%). Its shares were up more than 30% at one point this year, but they have since tumbled along with oil prices and are now down about 1% for 2019. That slump in Marathon Oil's stock, however, looks like a good buying opportunity for investors. That's because the company can produce a gusher of cash flow in the next year even if oil remains volatile.

An oil barrel with money spewing out of it with a happy man celebrating next to it.

Image source: Getty Images.

A two-year plan to cash in on lower crude prices

Marathon Oil is among the lowest cost U.S. shale drillers. At $45 a barrel, the company can generate the cash to pay its dividend and fund the drilling of enough new wells to grow its oil production by a 10% rate with some money left over. That excess cash flow rises sharply with the price of oil. At $50 a barrel, Marathon could produce more than $750 million in cumulative free cash flow by the end of 2020. Meanwhile, at $60, the company's free cash flow tally would rise to more than $2.2 billion. That's a lot of money for a company that currently has an $11.6 billion market value.

The oil company's cash-generating ability was on full display during the first quarter. Marathon produced $80 million in excess cash after paying its dividend by capturing an average of $55.14 per barrel for its U.S. output during the quarter. While oil prices have moved around quite a bit during the second quarter, Marathon has hedges in place to lock in a price above $55 a barrel for a large portion of its production. Because of that, it should have produced another healthy dose of cash during that period.

All that cash has only one place to go

Since Marathon Oil can fully fund its growth engine on $45 oil, and it has one of the best balance sheets in its peer group, the company does not need its growing stream of excess cash. That's why it has been returning this money to shareholders through its stock repurchase program.

Marathon Oil produced $865 million of free cash flow last year after paying its dividend and used the bulk of those funds to buy back $700 million of its stock. It followed that same blueprint during the first quarter, using $50 million of its $80 million in free cash to buy back shares. Those repurchases have already enabled the company to retire more than 4% of its outstanding shares.

With the company on track to continue generating significant free cash flow, the share count should keep heading lower. As noted, the company could produce more than $2 billion of free cash by the end of next year, which is enough money to retire another 17% of its outstanding shares at the current trading price.

Those future repurchases should help boost Marathon's stock price. That has been the case for fellow low-cost shale producer Devon Energy (DVN 0.18%). The company has used its free cash flow and the proceeds from asset sales to buy back $4 billion of its shares in the last year, which has reduced its outstanding share count by more than 20%. Those repurchases have helped drive Devon Energy's stock up by 25% this year, significantly outperforming shares of Marathon.

The big-time buyback could catapult shares in the coming year

Shares of Marathon Oil have underwhelmed this year even though it's generating gobs of free cash flow that it's returning to investors. However, with the oil producer on track to produce even more excess cash, it has the potential to repurchase a significant amount of its underperforming stock in the next year. That meaningful buyback should eventually begin driving up shares of Marathon Oil, which is why it looks like a compelling oil stock to consider buying right now.