Commodities have been giving investors fits for years. Just take a look at the following chart of several key global commodities over the past decade.

Brent Crude Oil Spot Price Chart

Brent Crude Oil Spot Price data by YCharts

All four commodities have taken investors on triple-digit price rides with rapid ascents and devastating falls. It's that allure of a rapid rise that continues to draw investors in with hopes of making a mint on higher prices. However, given that prices can change on a dime, it's a warning to investors to stick with the companies that can survive the deepest of drops because as history shows, those drops are sudden. With that, here are five companies built to last, making them the best stocks to invest in commodities.

Energy commodities
While the price of oil is roughly flat over the past decade, it has taken investors on a wild ride in between. The recent end of triple-digit oil prices is now threatening many oil and gas producers after those higher prices in previous years encouraged many to borrow money to drill as many wells as possible. Now that prices have fallen those companies are in deep trouble.

On the other hand, ExxonMobil (XOM 0.27%) and Chevron (CVX 1.04%) didn't overspend during the boom years and blow up their balance sheets. Instead, the duo have two of the best balance sheets not just in the oil patch, but in the entire world as we can see on the following slide.

Source: ExxonMobil Investor Presentation.

In fact, Exxon's Triple-A credit rating puts it in a really elite group as only three U.S. companies boast that credit rating. The low leverage employed by both companies virtually assures that they won't go under should oil prices remain weak for an extended period of time. Further, the pair have some of the highest returns in the sector, making them true best-of-breed oil companies.

Base metal commodities
Base metals like iron ore and copper are key commodities for global growth as iron ore is important for steel making, while copper is a key construction material. Two of the leaders here are BHP Billiton (BHP -3.34%) and Freeport-McMoRan (FCX 2.62%) as both are not only top producers of key base metals, but are diversified across several key commodities. BHP Billiton's focus is on copper, iron ore, coal, and petroleum while Freeport-McMoRan is focused on copper, gold, and petroleum. That diversification makes both companies really great proxies for the global commodity space.

Of the two, BHP Billiton has the better balance sheet and as the slide below notes it has the highest credit rating in the mining sector.

Source: BHP Billiton Investor Presentation.

BHP Billiton's strong credit metrics means it's built to last through the lowest point of the commodity cycle.

Unfortunately, the same can't be said of Freeport-McMoRan as at the moment its balance sheet is a bit bloated with debt as a result of its recent foray into oil and gas. However, the largest publicly traded copper producer is right in the middle of several key copper expansion projects that are expected to lower its production costs, which will drive additional cash flow. Further, Freeport is raising cash by selling non-core mines and a minority stake in its oil and gas business via an IPO to keep its debt from growing any further. So, while its balance sheet isn't top-tier, it is improving.

Agricultural commodities
Another key commodity area for investors is agricultural commodities and one of the best investment opportunities in agriculture is investing in crop nutrients like potash. The top investment option here is Potash Corp (POT). Not only is the company the clear leader in worldwide potash production as it controls 20% of worldwide capacity, but it's also a key phosphate and nitrogen producer. All three crop nutrients are important to meeting the daunting task of growing worldwide food production to feed a growing population.

It's also worth noting that like Freeport-McMoRan, Potash Corp is nearing an end to a key expansion phase in potash production. Once complete the company will lower is production costs, which will boost its free cash flow. Further, those lower production costs are a great hedge against falling commodity prices, enhancing Potash Corp's ability to easily withstand a downturn in potash pricing.

Investor takeaway
The best commodity stocks have two things in common. First, all have strong or improving balance sheets, which will enable them to weather future downturns in commodity prices. In addition to that, all are leading producers, as size and scale enables them to earn higher margins than smaller peers as they can not only spread out costs over a larger base, but also negotiate lower rates due to their leading presence in the industry. It's what makes these five companies the best to invest in commodities.