The story of how Mr. Trump sidestepped a potentially ruinous tax bill emerged from documents recently discovered by The Times during a search of casino bankruptcy filings.

Mr. Trump structured his companies to allow him to have lucrative personal tax advantages, while limiting his personal liability should business go bad.

THE LIMITED PARTNER Mr. Trump can flow business gains and losses onto his personal tax returns. The casino is owned by the partnership. THE GENERAL PARTNER Mr. Trump’s corporation serves to limit his personal liability.

THE LIMITED PARTNER

Mr. Trump can flow business gains and losses onto his personal tax returns.

THE GENERAL PARTNER

Mr. Trump’s corporation serves to limit his personal liability.

TRUMP ASSOCIATES

The casino is owned by the partnership.

For each of his Atlantic City casinos, Mr. Trump formed a partnership between himself and a corporation that he wholly owned and created for this specific purpose.

At the time, many businesses, particularly real estate ventures, were structured similarly, with the goal of protecting owners from losing personal money should their businesses go bust. But Mr. Trump was playing on a vastly different scale than most; his leverage was the stuff of legend.

“There’s nothing like doing things with other people’s money, because it takes the risk,” Mr. Trump said at a campaign rally in September.

With the partnerships in place, Mr. Trump went looking for financing.

O.P.M. To finance the Trump Taj Mahal, Mr. Trump issued $675 million in bonds at a 14% interest rate. This is one of many ways Mr. Trump leveraged other people's money, known in investing as O.P.M.

O.P.M.

To finance the Trump Taj Mahal, Mr. Trump issued $675 million in bonds at a 14% interest rate. This is one of many ways Mr. Trump leveraged other people's money, known in investing as O.P.M.

To purchase and finish construction on the Trump Taj Mahal, for instance, Mr. Trump’s company sold over a half-billion dollars in bonds – essentially i.o.u.s with interest – to individuals, companies and banks.

Within the first year, Mr. Trump began missing interest payments, a bad sign for investors. The Taj, though, was far from the only Trump business that was hemorrhaging money.

PILING ON Many of Mr. Trump’s other businesses also suffered losses that flowed onto his personal tax returns.

PILING ON

Many of Mr. Trump’s other businesses also suffered losses that flowed onto his personal tax returns.

In the late 1980s and early 1990s, several of his casinos and other properties suffered significant losses, the majority of which ultimately ended up on Mr. Trump’s personal taxes.

Mr. Trump managed to turn these business losses to his personal gain — in the form of something called a net operating loss (N.O.L.).

TRUMP'S N.O.L. Mr. Trump amassed nearly $1 billion in net operating losses that he could use to offset personal income taxes for almost two decades.

MR. TRUMP’S N.O.L.

Mr. Trump amassed nearly $1 billion in net operating losses that he could use to offset personal income taxes for almost two decades.

But there was a threat to Mr. Trump’s N.O.L.: the debt forgiven by many of his creditors who were trying to salvage what was left of their investments.

TAXABLE INCOME When a debt is forgiven, it is seen as income by the government and subject to taxes.

TAXABLE INCOME

When a debt is forgiven, it is seen as income by the government and subject to taxes.

Mr. Trump’s forgiven debt – which included the renegotiated bonds used to finance the Trump Taj Mahal – was viewed by the government as taxable income, and as such could be deducted from Mr. Trump’s personal N.O.L.

Mr. Trump needed a way to protect his advantage. He found a valuable one.

NEW BONDS Mr. Trump issued new bonds to replace the old bonds. The new bonds have a lower return, essentially forgiving millions in debt, which could potentially decrease Mr. Trump’s N.O.L. THE SWAP To avoid taxes on the forgiven debt and protect the N.O.L., Mr. Trump used a partnership equity for debt swap that was subsequently closed by Congress.

NEW BONDS

Mr. Trump issued new bonds to replace the old bonds. The new bonds have a lower return, essentially forgiving millions in debt, which could potentially decrease Mr. Trump’s N.O.L.

THE SWAP

To avoid taxes on the forgiven debt and protect the N.O.L., Mr. Trump used a partnership equity for debt swap that was subsequently closed by Congress.

In a tax avoidance maneuver his own lawyers told him was legally dubious, Mr. Trump managed to avoid paying taxes on the forgiven debt by swapping partnership equity for debt. It didn’t matter if the actual market value of the equity was less than the forgiven debt. (Equity in an insolvent partnership could easily be next to worthless). This type of swap was made illegal for partnerships in 2004.