Image source: BP.

Investing in oil doesn't mean you need to buy a company that produces the stuff. Nelson Rockefeller would say it's way better to buy not the companies that produce the oil, but the ones that control the ability to take that crude oil and make it into something useful: refineries. 

To invest in refieries, though, there are a few things you should consider. So let's look at what separates a run-of-the-mill refinery from one you want to invest in over the long term, and then we'll take a peek at three companies in the refining space that are some of the best of the bunch. 

What to look for
Refiners are stuck in the middle between two commodity markets: crude oil and refined petroleum products. The success of any business in this space is exploiting inefficiencies between the price of crude and those refined products. Refiners can do so in a few select ways:

  1. Geography: Sometimes it's as simple as having built a refiner in the right place. Crude oil doesn't all sell for the same price because of things such as chemical composition or transportation capacity, and sometimes centers of demand can be a long way away from crude sources. So if a refiner can position itself geographically to source crude cheaply or be closer to a center of demand where refined products can get a slight premium, a company can boost its profits.
  2. Refining process complexity: A barrel of crude oil consists of hydrocarbon molecules of different shapes and sizes. Refining is a general way of saying that it's been separated based on these molecule sizes and weights. Some of these molecules are more valuable than others -- think gasoline versus asphalt. However, a refiner can add processes that can chemically alter those less desirable molecules into something in greater demand. These processes are measured based on what's called refinery complexity, and those refiners with more complex operations can normally take cheaper crudes with a less desirable mixture of molecules and transform them into a higher percentage of high-value products.
  3. Efficient operations: Running a refinery involves a lot of fixed costs, so you want it running at maximum capacity as much as possible to put those costs to work. Companies that keep a well maintained facility that runs at a high capacity and can keep its cash costs per barrel of product produced will generally generate the highest returns. 

Some refiners will have only one or two of these things going for it, and some rely on a particular trait more than others. Overall, though, the combination of these three factors will go a long way in determining which companies are the best refiners in the space. It's also not a coincidence that companies that can capture components of all three of these traits will generate excess cash flow from their operations to reward shareholders with dividends and share repurchases.

3 candidates for your consideration 
Marathon Petroleum (MPC -0.84%): The spinoff company of Marathon Oil is positioned in two unique ways. Its refineries in the Great Lakes region take advantage of cheap feedstocks coming down from Canada to supply its own large network of retail stations, stretching from New Hampshire to Illinois and Florida. On top of that, it has an even greater presence in the Gulf of Mexico, where it can export large volumes of refined products to international markets at higher-than-domestic prices. While the company might not be the most efficient operator in terms of per-barrel operating costs, it makes up for it by generating lots of excess cash and returning a majority of that cash in the form of a 2% dividend yield and $6.2 billion in share repurchases.

HollyFrontier (HFC): With so much of the nation's refiing capacity in the Gulf Coast and the Midwest, it's hard for a company like HollyFrontier to get a lot of geographic advantages from its refineries. So its focus has been on building some of the most complex refineries in the nation to handle all those heavy, hard-to-handle crudes no one else can take and turning them into high-value products. The companywide complexity rating for Hollyfrontier of 12.1 is the highest in the country. To make sure those facilities are adequately supplied with these types of crude and keeps its margins higher than average, the company is pouring money into several rail and pipe projects through its subsidiary Holly Energy Partners (HEP). These sorts of moves have allowed the company to produce the best return on capital employed among U.S. refiners over the past five years.

Northern Tier Energy (NYSE: NTI): This is probably one of the riskier investments in the refining space, because the company owns only one refinery. If something were to happen that forced that facility to shut down for an extended period, the company wouldn't earn a dime. That being said, the one refinery it owns has some components of all three advantages I mentioned earlier. Its location in Minnesota is able to source crude from Canada and North Dakota's Bakken formation for cheap because of the lower transportation costs. Its refinery complexity rating of 11.5 is the third best of any company in the nation, meaning it can take those heavy crudes from Canada and produce lots of gasoline from them. And its per-barrel cash costs are some of the best in the nation. As a variable-rate master limited partnership, it gives back all of its excess cash each quarter to shareholders, which has resulted in a dividend yield of better than 7.5% over the past year.

What a Fool believes
Now that U.S. and Canadian oil producers have discovered a new way to access billions of barrels of oil we once thought untouchable, refineries look to have ample supplies of oil for many years to come. So the companies that can continue to exploit the inefficiencies in the markets for crude oil and refined products -- and turn those advantages into cash -- have the potential to do extremely well and could make for a very compelling investment.