The S&P 500 is having a strong year. It recently closed at another all-time high, the 24th time it closed at a record in 2024. The broad market index is up more than 10% on the year and over 25% in the past 12 months.

Several catalysts have helped fuel the S&P 500 Index's record-setting performance this year. One factor that many investors might have overlooked is the effect that energy stocks are having on the index. Energy stocks listed in the S&P 500 have surprisingly outperformed that broader market index this year, as measured by the returns of the Energy Select Sector SPDR ETF.

^SPX Chart

^SPX data by YCharts

Here's a look at what's fueling the sector's returns and some of the S&P 500's unsung heroes.

Drilling down into what's fueling energy stocks this year

For the most part, energy stocks rise and fall with oil and gas prices. With energy stocks up in 2024, it's likely not surprising to learn that crude oil prices are higher this year. Brent, the global oil benchmark price, has risen about 7% to over $80 a barrel. Meanwhile, WTI, the primary U.S. oil price benchmark, is up nearly 10% to just under $80 a barrel. A few factors have helped fuel the rise in crude prices, including OPEC's continued support of the oil market by holding back supplies and concerns about the ongoing conflict in the Middle East.

Higher oil prices enable producers to make more money, which lifts their value. For example, oil giant ExxonMobil (XOM -0.84%) produced nearly $14.7 billion in cash flow from operating activities in the first quarter, a $1 billion increase from the fourth quarter. The oil giant delivered even stronger free cash flow growth (from nearly $8 billion to over $10 billion). Exxon returned about $6.8 billion of that money to shareholders via dividends ($3.8 billion) and share repurchases ($3 billion), with the rest of the cash piling up on its balance sheet ($33.3 billion at the end of Q1). Exxon's strong performance has helped fuel a nearly 18% gain in its share price this year.

The three best-performing energy stocks of 2024

While Exxon is having a strong year, other energy stocks have delivered even better returns. The top three performers in the S&P 500 are Targa Resources (TRGP -1.03%), Diamondback Energy (FANG -2.30%), and Valero (VLO 0.17%).

VLO Chart

VLO data by YCharts

Targa Resources is a little-known pipeline company. It's coming off a record year in 2023. It delivered record adjusted earnings before interest, taxes, depreciation, and amortization (EBITDA), which rose 22% last year, fueled by record volumes. The company expects 2024 to be a solid year (8% adjusted EBITDA growth) before its growth reaccelerates in 2025 as several expansion projects come online.

Those projects should drive meaningful free cash flow growth next year. That's giving Targa the confidence to return more money to shareholders (it boosted its dividend 50% earlier this year and has been repurchasing shares at a record pace). While Targa's stock is already up sharply this year, its strong growth profile could give it the fuel to continue rising.

Oil and gas producer Diamondback Energy has benefited from higher oil prices this year. It produced over $1.3 billion in cash from operating activities in Q1 and almost $800 million in free cash flow. It returned about half of its free cash to investors through dividends and share repurchases. The company should produce more cash in the future even if oil prices don't keep rising, fueled by its pending acquisition of Endeavor Energy Resources. That highly accretive deal will make it the top pure-play producer in the prolific Permian Basin.

Refining giant Valero rounds out the top three. The company reported strong Q1 results even though it had to work through a heavy period of planned maintenance activities, which affected its ability to refine oil. With its maintenance projects complete, Valero's earnings could be even stronger in the coming quarters. Meanwhile, Valero continues to make excellent progress in expanding into renewable fuels. Its renewable diesel production is soaring as it expands its capacity. In addition, the company expects to complete a sustainable aviation fuel project later this year, putting it in an even better position to continue growing its earnings amid the global energy transition to lower-carbon fuels.

Energy is quietly having a strong year

Energy stocks are benefiting from rising oil production and growing demand. That's enabling companies to generate more cash to fund expansion projects and return money to shareholders. While the world is slowly shifting away from fossil fuels, it will need oil and gas for decades to come. Because of that, investors shouldn't completely overlook energy stocks, since they have the potential to produce high-octane returns.