It's been a rocky few years for integrated oil company ExxonMobil (XOM 2.18%), which has navigated volatile commodity prices. The company's picked up a lot of debt, resorting to borrowing to pay its dividend during tough times like 2020 when oil prices temporarily went below zero. But that's old news; ExxonMobil's having a great year and stacked profits in its third-quarter earnings.

ExxonMobil's dividend once appeared on the chopping block, but that's no longer the case. Don't feel like you've missed the boat; I'll break down ExxonMobil's colossal turnaround and explain why it can still be a part of a diversified long-term stock portfolio.

The king of crude has returned

ExxonMobil has spent decades as one of the world's largest oil and gas companies, an industry titan that generates hundreds of billions in revenue each year. Commodity prices directly impact how profitable companies like ExxonMobil can explore, extract, and refine oil and gas.

A combination of lower commodity prices and higher capital spending over the years left Exxon using debt to fund its dividend at times. Free cash flow even turned negative during COVID-19, meaning any dividends paid during that time were with debt. Eventually, management pulled back dramatically on spending, focusing its dollars on its most important projects. You can see the drop in capital spending below:

XOM Capital Expenditures (TTM) Chart.

XOM Capital Expenditures (TTM) data by YCharts.

ExxonMobil currently breaks even at an average oil price of $41 per barrel, and oil prices have held well above that mark. The company had a huge third quarter as a result, generating a whopping $22 billion in free cash flow. Look for billions more in cash flow hitting the books in the fourth quarter if oil prices remain elevated.

The dividend is safer than ever

Arguably the most crucial result of ExxonMobil's strong year is the healing of the balance sheet that got it through years of low commodity prices. The company still has $45 billion in long-term debt but is now sitting on a whopping $30 billion in cash, so net debt is just $15 billion today. That puts the company's debt-to-capital ratio at 19%, below the low end of what management aims for. In other words, ExxonMobil is flush with cash and has the most financial flexibility it's had in years.

That should translate to a reliable and growing dividend. ExxonMobil has raised its dividend for 40 consecutive years, making it a Dividend Aristocrat, an S&P 500 member with at least 25 years of dividend growth. The dividend costs the company roughly $3.7 billion each quarter, so considering ExxonMobil's $22 billion in third-quarter cash profits, there is no longer much concern about the safety of those dividend checks.

With ExxonMobil thriving again, shareholders should feel great about the company's odds of raising the payout another 10 years to obtain its crown as a Dividend King.

Pursuing new opportunities

Retirees probably aren't as focused on the long-term prospects of ExxonMobil's business; a secure dividend for the foreseeable future might be all they care about. However, ExxonMobil can also be a healthy contributor to any younger investor's long-term portfolio.

ExxonMobil is sitting on some outstanding projects in areas like the Permian Basin and Guyana, where returns on investment could exceed 10% at oil prices as low as $35 per barrel -- these projects could potentially drive much of ExxonMobil's production through the remainder of the decade.

Management underlined a longer-term ambition at its 2022 Investor Day event to gradually increase its focus on low-carbon businesses like carbon-capture technology, biofuels, and hydrogen. Low-emission projects will fetch $15 billion in spending from ExxonMobil between 2022 to 2027. Today, 94% of ExxonMobil's operating cash flow comes from its Upstream, Downstream, and Chemical businesses. Management believes fossil fuel alternatives will become a meaningful contributor by 2030 and the primary business by 2050.

It might seem silly thinking this far into the future in 2022, but ExxonMobil is a big ship that turns slowly. There are both comforts in a reliable dividend you can receive today and a long-term vision that doesn't paint ExxonMobil as a dying dinosaur but as an innovative energy company with an eye toward the next era of the world's energy needs.