Over the long run, the stock market is a wealth-building machine. But over shorter periods, the directional movements of the major indexes can be highly unpredictable.

Over the past four years, the Dow Jones Industrial Average, S&P 500, and Nasdaq Composite have oscillated between bear and bull markets in successive years. If this pattern were to persist in 2024, it would portend a difficult year for equities.

A person holding an assortment of folded cash bills by their fingertips.

Image source: Getty Images.

Thankfully, there is no shortage of safe stocks to consider buying. By "safe," I'm talking about profitable, time-tested businesses that can thrive in virtually any economic climate. And since most online brokerages have removed commission fees and minimum deposit requirements, any amount of money -- even $1,000 -- can be the ideal amount to put to work in tried-and-true companies.

If you have $1,000 to invest, and you're absolutely certain this isn't cash you'll need to pay bills or cover emergencies, the following five stocks stand out as the safest (and smartest) buys for 2024.

Mastercard

The first safe stock that makes for a no-brainer buy with $1,000 in the new year is payment processor Mastercard (MA 0.07%), which recently pushed to a new all-time high.

Although Mastercard is cyclical, it benefits from the disproportionate nature of the economic cycle. Whereas the 12 U.S. recessions following World War II have lasted between two and 18 months, the typical period of expansion over this timeline has endured multiple years. Extended periods of economic growth have allowed Mastercard to take advantage of higher consumer and enterprise spending.

Another factor working in Mastercard's favor is its purposeful avoidance of lending. While becoming a lender would allow Mastercard to generate interest and fee income along with merchant fees, it would also expose the company to potential loan losses and credit delinquencies during inevitable downturns. Mastercard has no direct liability to loan losses since it doesn't lend. This is the secret sauce that helps it bounce back from downturns quicker than other financial institutions.

Furthermore, Mastercard has a sizable opportunity domestically and abroad. It's cemented itself as the United States' No. 2 payment processor by credit card network purchase volume, and it has a multidecade opportunity to organically or acquisitively expand its payment infrastructure into underbanked regions, such as Southeastern Asia, the Middle East, and Africa.

NextEra Energy

A second extremely safe stock that investors can scoop up in 2024 with $1,000 is the largest electric utility stock by market cap, NextEra Energy (NEE -1.36%).

One of the best aspects of utility stocks is the predictability of their operating cash flow. Homeowners and renters don't change their electricity consumption habits much from one year to the next. Additionally, electricity is a basic need if you own or rent a home. Regardless of what the U.S. economy throws consumers' way in 2024, NextEra can accurately forecast its operating cash flow.

What truly differentiates NextEra Energy from its peers is its renewable energy portfolio. NextEra had 70 gigawatts (GW) of capacity in operation, as of Sept. 30. Nearly half of this (34 GW) derived from renewables. No utility in the world is generating more capacity from solar or wind than NextEra Energy. This has helped reduce the company's electricity-generation costs and lifted its adjusted earnings growth to an annualized 9.8% since 2012.

To boot, NextEra Energy is a phenomenal value after a challenging year that saw Treasury yields soar. Its forward price-to-earnings (P/E) ratio of 18 is the lowest it's been since 2015, and the company's yield is back to 3%.

Warren Buffett at Berkshire Hathaway's annual shareholder meeting.

Berkshire Hathaway CEO Warren Buffett. Image source: The Motley Fool.

Berkshire Hathaway

The third top-notch safe stock you can confidently buy with $1,000 in 2024 is Berkshire Hathaway (BRK.A -0.76%) (BRK.B -0.69%). Take note that I'm specifically talking about Berkshire's Class B shares (BRK.B) since a single Class A share ($551,182/share) will set you back more than the average house in America!

The most obvious reason to buy shares of Berkshire Hathaway is that you (sort of) get billionaire CEO Warren Buffett as your portfolio manager. Since taking the helm in the mid-1960s, Buffett has overseen a 19.8% annualized return in his company's Class A shares (the Class B shares didn't debut until 1996). Although past performance is no guarantee of future results, a 58-year track record of doubling up the annualized total return of the S&P 500 suggests Buffett and his team know what they're doing.

Warren Buffett's love for passive income is a big reason for Berkshire's ongoing success. Berkshire's $372 billion investment portfolio is set to generate around $6 billion in dividend income over the next year. Companies that pay recurring dividends are typically profitable and able to offer transparent long-term growth outlooks. More importantly, income stocks have substantially outperformed non-payers over extended periods.

The Oracle of Omaha is also a big believer in cyclical businesses. Instead of trying to time when recessions will occur, Buffett and his investing aides allow time to be their ally. Having a portfolio packed with cyclical companies allows Berkshire Hathaway to take full advantage of extended periods of growth.

York Water

Safe stocks exist beyond the megacap space. Small-cap water utility stock York Water (YORW) is the perfect example of a surefire buy you can add to your portfolio with $1,000 for 2024.

York is a regulated utility that provides water and wastewater services to 54 municipalities in South-Central Pennsylvania. By "regulated," I mean the company can't increase rates on its customers without first getting approval from the Pennsylvania Public Utility Commission (PPUC).

While this might sound like a hassle, it's actually fantastic news. Regulated utilities avoid the prospect of potentially volatile and unpredictable wholesale pricing. As a result, York Water, like NextEra Energy, generates highly predictable operating cash flow.

It's worth noting that 2023 was a banner year for York. In January, the PPUC permitted the company to raise rates on approximately 75,000 of its customers. This rate increase will allow the company to recoup approximately $176 million in spending for system improvements and infrastructure replacements. It's expected to increase York's full-year revenue by about 22%.

Best of all, York Water is arguably "Wall Street's Greatest Dividend Stock." It's been paying a continuous dividend since its founding in 1816. The 207 straight years it's doled out a payout is 60 years longer than any other public company.

Johnson & Johnson

The fifth safe stock that makes for a smart buy in 2024 with $1,000 is healthcare conglomerate Johnson & Johnson (JNJ -0.46%), commonly known as J&J. Johnson & Johnson has increased its base annual payout for 61 consecutive years.

The beauty of healthcare stocks is that they're highly defensive. Regardless of how well or poorly the U.S. and global economies perform, people will continue to need prescription medicine, medical devices, and healthcare services. Since we have no control over when we become ill or what ailment(s) we develop, operating cash flow for healthcare companies tends to be highly predictable.

Johnson & Johnson's operating structure has certainly played a role in its success. It's been steadily shifting more of its revenue to pharmaceuticals for over a decade. Brand-name therapies afford J&J exceptional pricing power and are doing the heavy lifting when it comes to the company's operating margin.

Another reason investors can trust Johnson & Johnson is its first-class balance sheet. It's one of only two publicly traded companies that Standard & Poor's (S&P), a division of the more-familiar S&P Global, has bestowed with the highly coveted AAA-credit rating. S&P has the utmost confidence that Johnson & Johnson can service and repay its outstanding debt.

The cherry on the sundae for investors is that J&J's forward P/E ratio is at a decade low.