Donald Trump used an aggressive tax strategy that tax lawyers warned him could raise red flags to avoid paying taxes on hundreds of millions of dollars in income in the 1990s, according to a new report in the New York Times.

The tactic, the Times said, involved losses from his Atlantic City casinos. As a real estate developer, Trump would have been allowed to use his losses to offset taxes he may have owed on other business income.

At the same time, his creditors forgave much of his debt on the properties when they went bankrupt. Forgiven debt is normally treated as income for tax purposes. Instead, the Times said Trump may have used a complicated maneuver in which his real estate partnership issued stock -- to erase the taxes owed on his forgiven debt.

The stock may not have been worth much, but for tax purposes, that didn't matter.

"This particular maneuver was about as close as a company could get to waving a magic wand and making taxes disappear," the Times said.

Related: How Donald Trump could have - legally - paid no taxes

Last month, the Times obtained a few pages from Trump's 1995 state tax returns, which showed a $916 million business operating loss. Since then tax lawyers have been trying to figure out how he could claim such a large loss.

The Times report is based on documents the newspaper recently discovered during a search of the casinos' bankruptcy filings, which offer only a "partial description of events."

The report included letters from tax lawyers who warned that the "stock-for-debt-swap" strategy was not explicitly permitted and may not pass muster with the IRS.

The Times said it was unclear whether the IRS challenged Trump's use of the strategy.

By not reporting the forgiven debt from his casinos as income, Trump may have avoided paying income taxes on some $400 million to $450 million, said tax lawyer Steven Rosenthal, a senior fellow at the Tax Policy Center.

Related: How Trump could lose a billion bucks but still live a billionaire life

One of the fundamental problems underlying this whole scenario, according to one expert the Times cited, is that Trump could claim losses on properties that were financed with money raised from investors and loans from banks.

"He deducted somebody else's losses," said John L. Buckley, who served as the chief of staff for Congress's Joint Committee on Taxation in 1993 and 1994. Since the bondholders were likely declaring losses for tax purposes, Trump shouldn't be able to as well. "He is double dipping big time," Buckley told the Times.

Then if he employed what the Times characterized as a "contentious" strategy of swapping stock for debt in his circumstance, he pushed the envelope farther.

Congress acted to ban partnerships swapping stock for debt in 2004, according to the Times.

In a statement to the Times, Trump's spokeswoman Hope Hicks said: "Your e-mail suggests either a fundamental misunderstanding or an intentional misreading of the law. Your thesis is a criticism, not just of Mr. Trump, but of all taxpayers who take the time and spend the money to try to comply with the dizzyingly complex and ambiguous tax laws without paying more tax than they owe. Mr. Trump does not think that taxpayers should file returns that resolve all doubt in favor of the I.R.S. And any tax experts that you have consulted are engaged in pure speculation. There is no news here."

Given that Trump has steadfastly refused to release any of his tax returns -- defying a tradition of transparency that presidential candidates have adhered to for 40 years -- it remains impossible to ascertain exactly what Trump did to avoid paying taxes and just how aggressively he stretched the law to reduce his tax bills over time.