For most of the past few years, Macy's (NYSE:M) credit rating has teetered on the verge of junk territory. Weak performance in its core business -- combined with ill-advised, debt-fueled share buybacks in 2015 -- caused each of the three major credit rating agencies to downgrade Macy's ratings at least once in 2016 and 2017.

By the end of that process, Macy's credit rating sat just one notch away from junk status at both Moody's and S&P. Meanwhile, S&P and Fitch have both maintained a negative outlook on Macy's, indicating a substantial chance that they would downgrade its credit rating again.

However, Macy's has done an admirable job of cleaning up its balance sheet and stabilizing its profitability over the past two years or so. As a result, in the past week, S&P and Fitch have both said that Macy's is no longer under review for a potential ratings downgrade.

Macy's leverage ratio has recovered quickly

Several years ago, Macy's experienced sharp deterioration in its earnings power, with adjusted earnings before interest, taxes, depreciation, amortization, and rent (EBITDAR) falling from $4.2 billion in fiscal 2014 to $3.2 billion in fiscal 2016. This caused its leverage ratio -- adjusted debt divided by adjusted EBITDAR -- to balloon from 2.6 times in early 2015 to 3.3 times in early 2017. (Lower numbers indicate a more conservative balance sheet.)

After briefly hoping that an earnings rebound would fix the company's leverage problem, Macy's executives realized that paying down debt needed to be a top priority. As a result, the company suspended its share buyback program in 2017. Since then, Macy's has used the majority of its free cash flow and asset sale proceeds to reduce its debt, repaying $954 million in fiscal 2017 and $1.1 billion in fiscal 2018.

The exterior of Macy's Union Square flagship store in San Francisco

Macy's has repaid more than $2 billion of debt in the past two years. Image source: Macy's.

Meanwhile, adjusted EBITDAR has stabilized -- more or less -- thanks to improved sales trends. In fiscal 2018, Macy's comp sales increased 2.4% year over year.

The net result is that Macy's leverage ratio has recovered to pre-2015 levels. By the end of fiscal 2018, the company's adjusted debt was down to just 2.5 times EBITDAR, or 2.9 times EBITDAR excluding asset sale gains.

S&P and Fitch believe in Macy's strategies

Macy's management has indicated that it plans to continue reducing its debt in fiscal 2019, albeit at a slower pace than in the past two years. That plan helped influence the recent decisions by analysts at both S&P and Fitch to remove their negative outlooks for Macy's credit rating.

That said, it's also clear that the S&P and Fitch analysts are optimistic about Macy's sales growth strategies. Both ratings agencies stated that they expect comp sales growth to be flat or slightly positive in the years ahead, driven by store and technology investments, as well as the continuing rollout of the Macy's Backstage off-price concept to more stores. That should allow Macy's to maintain roughly stable earnings in the years ahead. Without that expected earnings stability, Macy's would remain vulnerable to ratings downgrades in spite of its debt reduction efforts.

These forecasts from the ratings agencies are roughly in line with the company's guidance for fiscal 2019. Moreover, if Macy's fiscal 2018 performance is a guide, the department store giant's full-year forecast may be extremely conservative.

Room to maneuver

Achieving stable outlooks from all three major credit ratings agencies is great news for Macy's. For the past two years, Macy's has been on a short leash, particularly because it was one wrong move away from having its S&P credit rating fall into junk territory.

Looking ahead, Macy's now has more flexibility to resume its share repurchase program, as long as it doesn't take on additional debt to fund buybacks. With Macy's stock trading for just eight times forward earnings -- and ample opportunities remaining to unlock real estate value -- even a modest level of share repurchases during fiscal 2019 could create significant long-term value for Macy's shareholders.