At the time, Mr. Trump would have been hard-pressed to pay tens of millions of dollars in taxes. According to assessments of his financial stability by New Jersey casino regulators, there were times in the early 1990s when Mr. Trump had no more than a few million dollars in his various bank accounts. He was so strapped for cash that his creditors were apoplectic when they learned that Mr. Trump had bought Marla Maples an engagement ring estimated to be worth $250,000.

It is unclear who first glimpsed a way for Mr. Trump to dodge a huge tax bill. But the basic maneuver he used was essentially a new twist on a contentious strategy corporations had been using for years to avoid taxes created by canceled debt.

The strategy, known among tax practitioners as a “stock-for-debt swap,” relies on mathematical sleight of hand. Say a company can repay only $60 million of a $100 million bank loan. If the bank forgives the remaining $40 million, the company faces a large tax bill because it will have to report that canceled $40 million debt as taxable income.

Clever tax lawyers found a way around this inconvenience. The company would simply swap stock for the $40 million in debt it could not repay. This way, it would look as if the entire $100 million loan had been repaid, and presto: There would be no tax bill due for $40 million in canceled debt.

Best of all, it did not matter if the actual market value of the stock was considerably less than the $40 million in canceled debt. (Stock in an effectively insolvent company could easily be next to worthless.) Even in the opaque, rarefied world of gaming impenetrable tax regulations, this particular maneuver was about as close as a company could get to waving a magic wand and making taxes disappear.

Alarmed by the obvious potential for abuse, Congress and the I.R.S. made repeated efforts during the 1980s to curb this brand of tax wizardry before banning its use by corporations altogether in 1993. But while policy makers were busy trying to stop corporations from using this particular ploy, the endlessly creative club of elite tax advisers was inventing a new way to circumvent the ban, this time through the use of partnerships.

This was the twist that was especially beneficial to Mr. Trump. Wealthy families like the Trumps often own real estate and other assets through partnerships rather than corporations. Mr. Trump, for example, owned all three of his Atlantic City casinos through partnerships, an arrangement that allowed casino profits to flow directly to his personal tax returns when times were good.