Elon Musk says that the world needs more oil and gas, and he's right. When one of the world's wealthiest individuals -- who has made his fortune developing automobiles that reduce the planet's fossil fuel needs -- says that more oil and gas production is needed, people take notice.

At an energy conference in Norway, the Tesla (TSLA -1.11%) CEO said that, "Realistically, I think that we need to use oil and gas in the short term, because otherwise civilization will crumble."

Musk is a proponent of renewable energy, but recognizes that the world will need both fossil fuels and renewable energy to meet the planet's growing energy needs, and that a transition to renewable energy will take decades to complete.

Musk says, "One of the biggest challenges the world has ever faced is the transition to sustainable energy and to a sustainable economy... ." 

Oil worker oil rig natural gas

Image source: Getty Images

Is Musk right? 

The U.S. Energy Information Administration agrees with Musk, forecasting that consumption of oil and other liquid fuels will rise to 99.4 million barrels a day in 2022 and 101.5 million in 2023. Further out, the International Monetary Fund predicts that oil demand will peak around the year 2040. While this does mean demand for oil will eventually decline, that is 18 years from now, so oil is going to be needed for a long time to come as population growth and further economic expansion in developing countries will continue to drive demand.

With that in mind, here are three top oil and gas stocks that investors can buy and hold over the long term while this transition takes place.

1. Canadian Natural Resources 

Canadian Natural Resources (CNQ 0.81%) is one of Canada's leading oil and gas companies, with an extensive presence in Alberta's oil sands, as well as offshore operations in the North Sea and off Africa.

The company has a strong commitment to returning capital to shareholders and creating value for shareholders on a per-share basis. Shares yield over 4%, and management recently announced a special dividend of 1.50 Canadian dollars ($1.15) per share. The special dividend is a reward for shareholders after the company doubled its cash flow during the second quarter.

The company is also targeting using 50% of free cash flow, which it defines as adjusted funds flow minus base capital expenditures and dividends, for share repurchases and the other 50% for its balance sheet. When the company cuts net debt to $8 billion, it will increase its returns to shareholders.

If oil prices were to plummet, this could put a damper on Canadian Natural's plans, but the company deserves credit for making the most of 2022's higher oil prices to reward shareholders and improve its balance sheet. Furthermore, the company's assets in Alberta's oil sands are known for their long lives and low cost of extraction, meaning that Canadian Natural Resources has an attractive cost profile on its production. 

Even after a strong performance in 2022, shares of the company are still attractively valued at just under 8 times earnings. With a low cost of production, an attractive valuation, and a strong commitment to creating shareholder value, Canadian Natural Resources looks like a long-term buy. 

2. ExxonMobil 

ExxonMobil (XOM -2.78%) is the world's largest integrated oil and gas company, with a market cap of over $400 billion. The company has paid out a dividend for over 100 years in a row, and it has increased its payout for the last 39 straight years. The company continued to pay out and increase its dividend when other oil companies suspended or reduced their dividends during the pandemic. 

Besides this reliable payout, ExxonMobil is returning capital to shareholders via share buybacks, recently announcing a massive $30 billion repurchasing authorization, which triples the size of its previous program and equates to about 7.5% of the company's current market capitalization. The company is firing on all cylinders right now and reported record earnings and cash flow in its most recent 8-K filing. ExxonMobil is also investing in emerging renewable-energy technology like blue hydrogen and carbon capture and storage. 

3. TotalEnergies

While ExxonMobil and Canadian Natural Resources trade at attractive valuations, TotalEnergies (TTE 1.10%) is even cheaper. Shares trade at just under 7 times earnings and less than 5 times consensus forward earnings. The company is based in France, so some discount is likely warranted given the risks assoiated with exposure to Russian liquified natural gas (LNG) and the French government proposing windfall taxes on resrouce companies, but the stock looks like a bargain.

Shares of TotalEnergies yield even more than the two stocks above with a dividend yield north of 5%. It deserves credit for not cutting its dividend like its European competitors Shell and BP during the pandemic. The company is also returning capital to shareholders via share buybacks, repurchasing more than $2 billion worth of its own shares last quarter.

TotalEnergies has the world's second-largest LNG business, a good distinction at a time when natural gas demand is expected to increase over the long term as a cleaner alternative to coal. The company also seems to be on the same page as Musk in terms of a multifaceted approach to energy. Besides oil and gas, it has also invested in solar and offshore and onshore wind projects to grow its footprint in renewable energy.

These three companies all offer attractively-priced ways to play the ongoing need for oil and gas while receiving sizable returns in the form of dividends and share buybacks in the process. Musk is never shy about sharing his opinions, and in this case, he was absolutely right: Oil and gas are here to stay for a long time, making these leading energy stocks solid long-term investments.