Investing in oil stocks used to be a no-brainer. A growing world population and increasingly globalized economy requires vast amounts of fossil fuels to heat homes, ship goods across the ocean, and fuel jet-setters around the world.

Business is a lot less certain for participants in the oil and gas industry these days. Global oversupply of crude oil and natural gas, combined with fluctuations in demand, have caused the energy sector to significantly underperform the broader stock market in recent years. Major oil price crashes in 2014 and 2020 rocked the entire industry. And renewable energy continues to get cheaper and more widely used while governments are increasingly pushing businesses to lower their carbon emissions.

Even so, an investment in oil can still offer value. Here's a look at how to invest in the oil market. 

Keep an eye on oil prices

One of the biggest factors governing the oil industry is, of course, the price per barrel of crude oil. When crude oil prices rise, oil stock prices tend to go up, too. When crude oil prices tumble, so will the prices of most oil and gas stocks. For example, when global demand for fuel crashed because of the COVID-19 pandemic, oil stocks were among the hardest hit.

The reasoning behind this is pretty simple. The costs of getting oil out of the ground, transporting it, storing it, and refining it into fuel and other products are essentially fixed. When a barrel of crude oil can be sold for more than the sum of those costs, oil companies make money. But when oil is trading for less than the sum of those costs, at least some of those companies lose money.

It's generally better to buy oil stocks when oil prices are low and expected to rise rather than when they are already high. However, the price of oil affects different types of oil stocks in different ways. Checking out the recent price of oil is a critical first step in oil investing.

A row of oil derricks.

Image source: Getty Images.

Know the differences among oil stocks

Not all oil stocks are created equal. In fact, "oil companies" may operate in entirely different parts of the industry. It's important to know what kind of oil company you're investing in before you buy.

  • Upstream oil and gas companies, also known as exploration and production companies, or simply E&Ps, explore locations around the world for oil, and, once they discover it, drill wells to extract it from below the ground or seafloor. E&Ps are the most susceptible to fluctuations in the price of oil. The largest E&P in the U.S. is ConocoPhillips (NYSE:COP).
  • Midstream companies transport, process, and store crude oil, natural gas, natural gas liquids (NGLs), and refined petroleum products such as lubricants. Midstream companies often do business using fixed-rate, long-term, or take-or-pay contracts. Thus, their profitability is less affected by oil price fluctuations. The master limited partnership Enterprise Products Partners (NYSE:EPD) is a major midstream company. 
  • Downstream companies refine crude oil into other products like fuel or petrochemicals or sell refined products to consumers. Some do both. Gas station operators and refinery operators are two types of downstream companies. The price of oil impacts refineries' profitability because they make their money on the "crack spread," meaning the difference between the price of oil and the price of refined products. As such, downstream stocks often take a hit when oil prices fall since lower demand for refined products is one of the things that can weigh on crude prices. Phillips 66 (NYSE:PSX) is a major downstream company. 
  • Integrated companies operate in more than one of the above segments of the supply chain. The so-called "integrated majors," sometimes referred to as "Big Oil," have large upstream and downstream operations and some midstream capability as well. ExxonMobil (NYSE:XOM) and Chevron (NYSE:CVX) are two such oil majors.
  • Oilfield services companies provide equipment, operational support, and services to upstream companies. These can include onshore or offshore drilling rigs, drill bits, subsea robots, or pressure valves. When oil prices are low, upstream companies often try to cut their services costs, which hurts oilfield services companies. 

Oil exchanged-traded funds (ETFs) allow you to invest in an entire subsector of the oil industry at once as opposed to any single oil company. ETFs are baskets of stocks that are traded much like ordinary stocks. One noteworthy oil ETF is the SPDR Oil and Gas Exploration & Production ETF (XOP), which tracks the upstream subsector as a whole.

Focus on the dividend

Oil companies' struggles don't seem likely to disappear anytime soon. Even if they go through a period of short-term calm, such as the period between 2017 and 2019, global events outside their control can quickly set them back on their heels. That's why, for long-term investors who don't want to have to constantly monitor the oil markets, dividend investing is probably the best choice here. 

Integrated oil companies ExxonMobil and Chevron have been increasing their dividends annually for decades, with management prioritizing dividend preservation. Likewise, many midstream companies -- especially those with master limited partnership (MLP) structures -- offer high dividend yields and reliable payouts. 

When you're evaluating an oil company, don't just look at the dividend yield (also known as the dividend-to-share price ratio). Compare the yield to the company's free cash flow. The best companies can pay their total dividend obligations and fund their capital expenses using free cash flow, with some money left over. Further, look for a strong investment-grade balance sheet since that provides additional financial flexibility (more and better access to capital) and increases the probability that the company can maintain its dividend during the next industry downturn. 

How to invest in oil stocks

It's important for investors to be aware of the oil sector's volatility. Because of that, it's best to focus on companies built to weather the sector's inevitable downturns. That means focusing on those with relative immunity to price fluctuations, such as E&Ps with ultra-low production costs and integrated oil giants. Midstream companies, with their contracts, should also be able to deal with adverse market conditions more easily than others in the supply chain.

Another way to invest in the oil patch is to focus on using it to generate dividend income. Many companies in the sector pay dividends with attractively high yields. However, given the sector's overall volatility, investors need to choose their oil-fueled dividend stocks carefully, focusing on those with the balance sheet strength and cash flow durability to deliver dependable income streams.