Photo: Harry Hamburg/NY Daily News via Getty Images

It was the early ‘90s and Donald Trump had a tax problem. The mogul had financed three Atlantic City casinos via $1.3 billion in debt, mostly in the form of junk bonds. Then all three fell into bankruptcy and his bondholders were forced to forgive hundreds of millions of dollars to salvage any portion of their ill-advised investment.

But the IRS would be less forgiving. Canceled debt counts as income. If Trump reported his bondholders’ act of mercy, he’d be on the hook for a multi-million-dollar tax bill — one that very well could have ruined the Trump Organization right then and there. According to contemporary reports from New Jersey casino regulators, Trump spent much of the early ‘90s with a mere few million dollars in his bank accounts. Creditors scolded him for buying Marla Maples a $250,000 engagement ring. Things were not “big league.”

But Trump has always had a gift for making other people pay for his mistakes. And this time, it would be the American taxpayer: The mogul would avoid reporting hundreds of millions in taxable income by pursuing a tax-avoidance scheme so dubious, his own lawyers suggested it likely breached the bounds of legality, according to documents newly obtained by the New York Times.

Trump’s maneuver was modeled on a strategy that was used by corporations until it was outlawed in 1993. Before then, companies would avoid reporting canceled debt by offering their creditors a “stock-for-debt swap.” The market value of that stock might be worthless (shares in an insolvent company aren’t hot commodities). But the creditors were already prepared to lose their money. And giving away worthless stock allowed the corporations to dodge their tax bills.

But while Congress had barred companies from doing this, they hadn’t explicitly banned partnerships — like those through which Trump owned his casinos — from doing the same with equity. Sure, the government had repudiated the underlying concept, a point Trump’s lawyers made in tax opinion letters. But the casino magnate decided to take the gamble.

And, apparently, he won. A little over a month ago, the Times reported that Trump had claimed a $916 million loss in 1995, a sum large enough to absolve him of any income-tax liability for more than a decade. Writing off losses is a standard and defensible part off our tax code. But analysts puzzled over how Trump could have posted such an extravagant one. It now appears that Trump’s $916 million loss was likely inflated by his failure to report his bondholders’ hundreds of millions in canceled debt. (This can’t be determined with certainty because the Republican nominee has broken with decades of precedent and refused to release his tax returns.)

After news broke of Trump’s near-billion-dollar loss — and the years of tax-free living that likely followed it — the mogul tried to turn his political liability into his opponent’s.

“Why didn’t she ever try to change those laws so I couldn’t use them?” Trump asked supporters at a campaign rally this month.

In 2004, Congress banned equity-for-debt swaps by partnerships. Among the senators who voted for the law was Hillary Clinton of New York.