A U.S. Tax Court judge, in a decision potentially involving thousands of cases and tens of millions of dollars in back taxes, has issued the first ruling against a controversial commodity trading scheme designed to avoid taxes.

Judge Arthur L. Nims III ruled that losses claimed by two California real estate developers in a series of transactions engineered by Merrill Lynch were not deductible because the taxpayers were seeking only to avoid taxes, not to make profits.

At the heart of the case is a now generally outlawed commodity trading technique known as a tax straddle. Essentially what it did, before the tax loophole was closed by Congress in the Economic Recovery Tax Act of 1981, was to defer a profit to the next year and transform a heavily taxed short-term profit into a more lightly taxed long-term capital gain.

The Internal Revenue Service has claimed since 1977 that such transactions are illegal. Brokerage firms, including Merrill Lynch, differed with the IRS interpretation and continued to promote the tax relief schemes. As a result, thousands of cases involving earlier transactions are pending before the tax court or are being investigated by the IRS.

Many of those cases probably will be settled now, according to a source familiar with the case. In addition to siding with the IRS on the question of whether the investors entered into the transaction sincerely believing that they might make a profit, the court also ruled that the transactions involved gyrations designed to make the loss higher than it should have been. Instead of the $95,000 loss the taxpayers claimed, their real loss was about $5,000.

The ruling came in a case that Merrill Lynch had tried to prevent from going to trial by offering to pay the customers $114,000, or twice as much as the government claims the customers owe in taxes, to drop the case. Judge Nims would not allow the case to be dropped, however.

The customers were two California couples, Henry and Patricia Smith and Herbert and Ruth Jacobson, who made substantial profits on a real estate venture. Through Merrill Lynch's San Diego office, the couples arranged a series of silver trades that enabled them to avoid paying taxes on their real estate profits.

When the IRS audited their tax returns, it refused to allow the silver tax deductions. The couples challenged that decision and sued the IRS in Tax Court.

The IRS alleged, and the Tax Court agreed, that in 1973 and 1974, the taxpayers and their brokers entered into so-called tax straddles in order to make paper losses of about $100,000 in 1973 (to offset similar short-term gains that year) and earn about the same amount of gains in 1974 that would be taxed at a lower rate than the original profit.

The commodity tax straddle itself essentially was a net wash for the taxpayers. It created a loss in one year and a similar-sized profit for the next year. But because the profit was taxed at a long-term rate, which levies taxes on only half of it rather than at the short-term rate which assesses tax on the whole amount, the taxpayers stood to save a good deal of money if the transaction was upheld.

The court also ruled that the method Merrill Lynch used to determine the amount of the loss was in error. When tax straddles--usualy done in silver--were in their heyday on the New York Commodity Exchange, brokers would meet after trading was over and decide at which price they would exchange tax straddle contracts in order to maximize losses or gains for the owners of the contracts. The Comex stopped the practice in 1976.