Investors are once again turning their attention to oil and gas companies as the energy sector emerges as the top performer among the S&P 500’s 11 segments this quarter, showing a remarkable 12% increase.

This comes as a stark contrast to the sector’s earlier struggles when it was down approximately 13% year-to-date through mid-March. During that period, concerns about a slowing global economy and weakened energy demand weighed heavily on oil prices.

However, a recent shift in fortunes has propelled energy stocks to the forefront. Extended production cuts by two of the world’s largest crude oil exporters, coupled with optimism regarding the U.S. economy’s ability to avoid a recession, have pushed oil prices to $90 per barrel, their highest level of the year. This surge in oil prices has provided a significant boost to energy stocks.

Bill Fitzpatrick, Managing Director at Logan Capital, expressed the sentiment that there is no spare capacity to meet the rising oil demand, indicating that investors should position themselves for an extended period of higher oil prices, which appears to be the most likely scenario.

As a result, Fitzpatrick has been actively increasing allocations to energy shares in his firm’s international stocks portfolio, which currently stands at 11%.

While rising crude oil prices traditionally benefit energy stocks, they also present challenges. Elevated oil prices can lead to increased costs for everyday items like gasoline and consumer goods, potentially exacerbating inflation concerns.

This, in turn, could complicate the Federal Reserve’s efforts to conclude its interest-rate hiking campaign, as higher interest rates can offer investors more attractive alternatives to stocks.

Nate Thooft, Chief Investment Officer of the multi-asset solutions team at Manulife Investment Management, acknowledged that higher oil prices could create anxiety for the Fed. Nonetheless, for the time being, investors continue to show a strong appetite for energy stocks.

In August, the Alerian MLP exchange-traded fund, comprising companies involved in crude oil transportation and marketing, recorded net inflows of $132 million, the highest monthly inflow since February 2022.

One compelling factor behind the renewed interest in energy stocks is their relative affordability. According to FactSet, companies within the S&P 500 energy sector are trading at approximately 12 times projected earnings for the next 12 months, a valuation below the 10-year average of 19. In contrast, the broader index maintains a multiple of approximately 19.

While the energy sector has posted a respectable 4.3% gain for the year so far, it still lags behind the S&P’s overall 16% increase. Energy stocks, however, remain susceptible to the cyclical nature of commodity markets.

In 2022, Russia’s invasion of Ukraine sent oil prices soaring, making the energy sector the sole segment of the S&P 500 to conclude the year with gains, achieving its best year on record.

Earlier this year, concerns over China’s shaky economic recovery and apprehensions about higher interest rates sparking a recession weighed on oil prices. To counter this, other oil-producing nations ramped up output, and the U.S. tapped into crude reserves to maintain supply levels, further suppressing prices.

Despite the sector’s volatility, some investors are staying committed to energy stocks. Gerald Goldberg, Chief Executive at GYL Financial Synergies, sees the appeal of the sector for clients seeking strong income, robust dividends, and attractive yields.