In a setback for the Internal Revenue Service's campaign against tax shelters, a federal judge in Maryland has ruled that a strategy employed by Black & Decker Corp. had a valid business purpose and the company is entitled to a $57 million tax refund.

"The court may not ignore a transaction that has economic substance, even if the motive for the transaction is to avoid taxes," U.S. District Judge William D. Quarles Jr. wrote in a brief opinion granting a legal victory to the Towson, Md.-based maker of power tools, hardware and home-improvement products.

"We are disappointed in the court's decision. We believe our position in this case is supported by the facts and the relevant law," Eileen J. O'Connor, assistant attorney general for the Justice Department's Tax Division, said in a prepared statement. The agency argued that the case should have been decided at a trial and had urged the judge to deny the company's request for summary judgment. The Justice Department could appeal.

The strategy in dispute is known as accelerating contingent liabilities. The IRS said it was promoted by the Deloitte & Touche LLP accounting firm, and the agency listed it as an abusive tax shelter.

The strategy allows a company to deduct immediately costs that would normally be payable, and deductible, only over a period of years, if ever.

In the Black & Decker case, the company had sold several of its business units in 1998, generating a substantial capital gain. The same year, it created Black & Decker Healthcare Management Inc., and transferred to it $561 million in cash and $560 million in potential employee health care claims. In return it received stock in the new company.

Black & Decker then sold that stock for $1 million. On its 1998 tax return, it claimed that the stock had cost $561 million and thus it was entitled to a capital loss of about $560 million. When the IRS refused to give the company a refund, it sued the agency.

Company officials could not be reached last night, but Black & Decker noted in a posting on its Web site that a decision in favor of the IRS would have resulted in "a cash outflow . . . of approximately $140 million."

The judge held that since the new company had assumed responsibility for managing Black & Decker's employee health care plans, and because it became responsible for paying those claims, "the BDHMI transaction . . . had very real economic implications for every beneficiary of [Black & Decker's] employee benefits program as well as for the parties to the transaction." Thus, the transaction "cannot be disregarded as a sham," he said.

The IRS had argued that 34 days after transferring the $561 million to the new company in exchange for stock, Black & Decker received the same amount back from the new company as a loan. Under the loan terms, Black & Decker must make payments to the new company to match what is needed to pay the Black & Decker employee health care claims, the IRS said.