Just a handful of mostly tech-focused companies have contributed the bulk of the S&P 500's year-to-date (YTD) gains. But that doesn't mean tech is the only sector winning in 2024.

In fact, the energy, materials, industrials, utilities, and financial sectors are all beating the S&P 500 over the last month. Meanwhile, communications, financials, energy, and industrials are the only sectors beating the S&P 500 YTD.

In a market where artificial intelligence (AI) drives so many narratives, it can be refreshing to see legacy companies outperform the benchmark. Let's look at what is fueling the industrial-sector rally and how to approach the sector.

Construction machinery at a dig site.

Image source: Getty Images.

A widespread rally

The industrial sector includes many different industries from package-delivery companies like United Parcel Service and FedEx, to defense contractors like RTX and Lockheed Martin, to conglomerates like Honeywell International. But what is particularly interesting about the sector is the strength of heavy-machinery companies.

Here are the 10 largest U.S.-based farm, heavy construction, and specialty industrial-machinery companies by market cap. With the exception of Deere (which is still beating the S&P 500 over the last five years), all of these stocks are within 2% of their all-time highs.

GE Chart

GE data by YCharts.

Despite the run-up, most of these stocks' price-to-earnings (P/E) ratios aren't terribly high relative to the S&P 500's 28.4 P/E ratio. That tells us that a lot of the rally is driven by earnings growth, not just valuation expansions.

GE PE Ratio Chart

GE PE Ratio data by YCharts.

Fueling the boom

Many heavy-machinery companies sell to other businesses, not to consumers. Similarly, many tech companies, from Nvidia, to Salesforce, to cloud-infrastructure providers like Amazon Web Services and Microsoft Azure, also sell to other businesses.

The market can be carved up into seemingly limitless categories. But one of the simplest designations is business-to-business-focused companies versus consumer-focused companies.

A divide is forming in the market where many business-to-business companies are doing very well, and some (but not all) consumer-focused companies are struggling. The most recent examples were Nike and Lululemon, which suffered major sell-offs on March 22 after disappointing earnings reports. Apple and Tesla are mainly consumer-focused, and they've been under pressure, while many other big tech stocks are crushing it.

In short, industrials are on the right side of the market right now, and that's definitely playing a part in the sector's rally.

Balanced companies with room to run

Many heavy-machinery companies are cyclical and putting up record earnings right now, but earnings will eventually fall, and valuations will look more expensive. One of the benefits of investing in leading industrial companies is that there's potential upside from growth, but there's also stability from dividends and stock buybacks.

Illinois Tool Works (ITW -0.86%) is an excellent example of delivering shareholder value through dividends, buybacks, and capital gains. Over the last 10 years, the stock has beaten the S&P 500, the dividend is up more than threefold, and the share count is down by 27.6%. Illinois Tool Works is also a Dividend King with over 50 consecutive years of divined raises. The company has improved its margins and focused on bottom-line growth instead of sales growth -- a strategy that has rewarded shareholders.

Illinois Tool Works encapsulates the effectiveness of the business-to-business strategy during a challenging time of high interest rates. The prospect of lower interest rates could allow the cycle to sustain momentum. Wall Street loves future growth, and the industrial sector has it.

Investing in the industrial sector

There are plenty of ways to invest in the sector besides scooping up shares of an industry leader.

The Industrial Select Sector SPDR fund (XLI -0.74%) is one of the simplest ways to get baseline exposure to the sector without breaking the bank on fees. The fund's mere 0.09% expense ratio means that investors pay just $9 in annual fees for every $10,000 invested. With 78 holdings, no individual holding making up more than 5% of the fund, and a market value of $17.7 billion, the fund is diversified and sizable. One drawback is that the yield is just 1.5%, which is mainly due to stock prices outpacing dividend-growth rates.

An alternative for passive-income-focused investors is the iShares Global Infrastructure ETF (IGF -0.25%), which has a 3.5% yield, a 21 P/E ratio, but a higher expense ratio at 0.41%.

The fund includes a variety of industrials, energy, and utility companies that contribute to global infrastructure. Many of the fund's international components have lower valuations, which make the ETF a good choice for investors looking for a higher yield and value.

A justified expansion

The industrial sector makes up 8.8% of the S&P 500, so it's not going to move the needle in the same way as tech. However, strong performance from industrials is encouraging for a broader market rally.

It shows that non-tech businesses with little to do with hot trends like AI are raking in the cash flow and delivering for their shareholders. The cycle could shift, and the sector could put up weak results in the short term. But there's every reason to believe it will do well over the long term.

The sector has a runway for sustained earnings growth and can reward shareholders with buybacks and dividends even during a downturn.

Despite sectors like industrials at all-time highs, the stock market remains an excellent tool for compounding wealth over time.