Oil and natural gas are hot, and so are American energy stocks. But investors, whether they have been along for the ride or are just thinking of joining now, may be wary of getting burned.

January through March of this year was the best quarter for the sector since 1970, according to BofA Global Research. While the S&P 500 is down roughly 13% year to date, the energy sector is up 49%. That follows a year when energy stocks beat the broader index by 21 percentage points.

Passive index investors didn’t get a huge lift from energy’s shining moment. Energy accounted for just 2.7% of the S&P 500 at the end of last year, a far cry from the 11% weighting the sector commanded a decade ago. And, according to BofA, active funds were significantly underexposed to the energy sector in the first quarter. Today, the weighting is at roughly 4.5%.

SHARE YOUR THOUGHTS

Energy stocks have been the top performers in a weak stock market this year. Do you feel confident that they can continue to shine? Join the conversation below.

Investors who are tempted by energy’s returns might be wondering if the rally has already run its course. Energy is a cyclical sector, after all: Exhilarating peaks tend to be followed by equally harrowing troughs. Periods of high prices either lead to more drilling or damped demand, until eventually the commodity’s price falls.

How far are we into this cycle? It has been a little over two years since the most recent trough (right around the time oil futures briefly went negative) and the sector’s market value has more than tripled since. The last two major cycles seem to imply the good times aren’t done: The last one—seen in the run-up to 2014—lasted about five years and four months, while the journey to the peak seen in 2008 took slightly longer than that (by another five months). The caveat is that the time it takes from trough to peak has only shortened, in part because of the exploitation of U.S. shale, where fracking has made oil-and-gas extraction a speedy process. The most recent cycle, the lead-up to a peak in 2018, wasn’t very dramatic or lengthy, taking about 2½ years.

But this time may be different. It is notable how disciplined U.S. oil-and-gas companies plan to be with their drilling—and not just as atonement for past excesses. While equipment and labor shortages have been a feature of almost every energy cycle, Dan Pickering, founder and chief investment officer of Pickering Energy Partners, notes that he has never seen today’s level of scarcity.

The U.S. Energy Information Administration estimates that crude oil production in the U.S. could increase by 800,000 barrels a day in 2022 and then another 900,000 barrels a day in 2023. While that seems like a lot, it is a snail’s pace compared to prepandemic years. In 2018 and 2019, the U.S. increased oil production by 1.6 million and 1.3 million barrels a day, respectively. Another factor affecting prices is a potential European ban on Russian oil imports, not all of which will find their way to countries like India and China. Before Russia’s invasion of Ukraine, the European Union was importing roughly 4 million barrels daily of crude oil and refined products from Russia.

The Energy Select Sector SPDR Fund, a widely followed ETF that tracks the energy sector in the S&P 500, is still 17% below its 2014 peak and 8% off its 2008 peak. The enterprise value of stocks in the fund is about 5.9 times expected earnings before interest, taxes, depreciation and amortization for the next 12 months—almost a fifth below its 10-year average. And the sector’s valuation on that metric is still 52% lower than the S&P 500 compared with the 34% discount the sector experienced on average over the past decade.

While a cyclical industry is always a risky bet, the energy sector today is—by some measures—the most investor-friendly it has been in a while.

Write to Jinjoo Lee at jinjoo.lee@wsj.com