Oil stocks are flops.

That may have been true in 2014, 2015, and even 2016, but in 2017, oil prices finally began to rise significantly above the critical $50-per-barrel mark. And oil and gas industry companies were poised to benefit.

However, some benefited a bit more than others -- particularly Royal Dutch Shell (NYSE:RDS-A) (NYSE:RDS-B)Statoil (NYSE:STO)HollyFrontier (NYSE:HFC), and ConocoPhillips (NYSE:COP).

Here's why they did so well, and what to expect from them in 2018.

A smiling man raises his arms next to an oil barrel above which is a cloud of paper money.

If you were lucky enough to buy one of these four oil industry stocks at the beginning of 2017, you should be happy with their outperformance. But will they do it again in 2018? Image source: Getty Images.

Royal Dutch Shell: Best of the biggest

The best oil stock of 2017 -- by just about any measure -- was Royal Dutch Shell. The oil major not only had an impressive stock rally, up 22.7% for the year, but also has one of the best dividend yields in the entire oil industry, at more than 5.6% (only BP's is higher, at about 5.7%).

The company's outperformance was far from a sure thing, though. In 2016, Shell took on about $50 billion in debt to acquire BG Group. While the acquisition increased Shell's exposure to the up-and-coming liquefied natural gas market, management announced it would sell $30 billion in non-core assets to try to get a handle on the company's debt. 

Shell's return metrics -- a measure of how well management is deploying the company's capital -- have also improved, as has the company's cash flow, thanks to some smart cost-cutting measures. Ultimately, Shell seems to simply be running more efficiently, and the market has taken notice. With oil prices on the rise, expect Shell to continue to outperform.

Statoil: Back in the game

Statoil had a surprisingly strong 2017. I say "surprisingly" because the company posted some big losses in 2015 and seemed headed for middling production growth.

Fast-forward to last year, and the company was able -- like many of its peers -- to successfully cut costs and generate a decent amount of cash flow at $50-per-barrel oil. In addition, Statoil has some ambitious projects in its pipeline, including a pair of offshore blocks in Suriname, right next door to ExxonMobil's promising Liza discovery in Guyana.

All that was enough to boost the company's stock by 17.4% in 2017. Couple that with a 4.1% dividend yield, and Statoil looks like a compelling prospect for 2018.

ConocoPhillips: Winning the losers' game

The largest independent U.S. oil and gas exploration and production company (E&P) was also 2017's biggest winner among its peers, with a stock price that rose 9.5% during the year. That isn't nearly as much as Statoil or Shell, of course, but considering that many E&Ps finished the year down 20% -- or more -- Conoco represents a rare bright spot in this corner of the industry.

Unsurprisingly, the company outperformed for many of the same reasons that Statoil and Shell did. It got rid of underperforming assets and used the cash to pay down debt, like Shell. It cut costs like Statoil. It also unveiled a clear shareholder-friendly plan and began executing it, to the delight of its investors.

Conoco will continue to reward shareholders into 2018, but there's a very strong case to be made that there are probably better values among the E&Ps whose shares were hammered in 2017 but that have made similar moves and will benefit from the same industry trends that boosted Conoco this year. 

HollyFrontier: Top of the heap

The most impressive performances in the industry came from some of the midstream (transportation and storage) and downstream (refining and marketing) companies. While several midstream-only companies -- particularly pipeline operators -- were down by more than 20% for the year, many downstream companies like Valero EnergyPhillips 66, and Marathon Petroleum were up by double digits. 

The biggest win among the large- and mid-cap refiners, though, was HollyFrontier, which saw its stock rise a jaw-dropping 56.4% in 2017, outpacing every other large- or mid-cap company in the industry. Even more impressive, that's not just a one-year fluke. Over the last three years, HollyFrontier's share price has risen 36.7%, while many upstream or integrated companies' stocks -- including those of Conoco and Shell -- are down over the same period.

HollyFrontier rode the same trends as its peers: An improving refining market and a busy summer driving season led to increased demand for refined petroleum products. HollyFrontier was ahead of the pack thanks to some savvy moves to take advantage of the price discounts from harder-to-process crudes from Canada and elsewhere. While we can't be sure whether the refining trend will continue, Holly's 2.6% dividend yield and past success should bode well for its continued performance versus its peers. 

Investor takeaway

2017's biggest winners are unlikely to be 2018's biggest winners, but all of these companies should do well, thanks to rising oil prices and improved fundamentals. 

However, investors may have better luck looking at the companies the market left behind in 2017 but that are still poised to benefit from the same trends as 2017's big winners. That way, there's a better chance that the biggest returns haven't already occurred.

John Bromels owns shares of HollyFrontier. The Motley Fool has no position in any of the stocks mentioned. The Motley Fool has a disclosure policy.