A district court judge delivered a blistering rebuke of the Federal Reserve Board on Wednesday, tossing out a central bank rule that caps debit card transaction fees and saying the central bank exceeded its authority.

The ruling is a big blow to bankers who had reluctantly come to accept the roughly 24 cent per transaction cap, and a significant victory for Sen. Richard Durbin, D-Ill. and retailers, both of whom had said the Fed's cap was set far too high. The decision, if not overturned, could cost banks several billions of dollars annually, on top of the more than $6 billion banks have already lost due to the Durbin Amendment.

In a harshly worded — at times even snarky — ruling, U.S. District Judge Richard Leon suggested that a seven-to-12 cent cap would be more in line with the law's intent.

Even more striking than the lopsided nature of the decision was its sarcastic tone. Responding to various arguments advanced by Fed lawyers, the judge wrote: "How convenient," "Not quite!" and "Please!"

"In short, the board's interpretation is utterly indefensible," Leon concluded.

It is not clear whether Leon, a President George W. Bush appointee, will get the final say. The Fed, which said only that it is reviewing the decision, could appeal his ruling to the District of Columbia's Court of Appeals. Or it could choose to revise its rules to comply with Leon's ruling.

The 58-page opinion allows the Fed's existing rules to stay in effect for now, but it also states that the central bank should move quickly to revise them.

Retailers joined Sen. Durbin, the author of the provision in the Dodd-Frank Act that mandated the Fed to take action, in celebrating the decision.

"The Fed's 2011 decision to bend to the lobbying by the big banks and card giants cost small business and consumers tens of billions of dollars and did not do enough to rein in the anti-competitive, anti-consumer practices of Visa and MasterCard," Durbin said in a news release.

Mallory Duncan, general counsel for the National Retail Federation, one of the merchant trade groups that sued the Fed, agreed.

"I think it's fair to say that the merchant community is ecstatic. The card market has been ossified for some time," he said in an interview.

Meanwhile, trade groups representing banks and credit unions decried the judge's opinion.

"The Fed's rule was already causing consumer harm, and now it looks like it will only get worse," read a statement from a coalition of financial industry trade associations. "If the past is any indication, the merchants will add even more to their $6 billion windfall, and consumers will still see none of the promised benefits."

Notably, community banks and credit unions stood arm-in-arm with large banks, which have borne the brunt of the Durbin Amendment's price caps, since the law carves out an exemption for small banks.

"While there is technically an exemption for certain financial institutions, community banks and their customers will be hurt by the Durbin amendment's price controls," said Camden Fine, president of the Independent Community Bankers of America, in a news release. "We're very concerned that any new version of the caps will leave them in an even worse position."

The merchants' lawsuit, filed in November 2011, hinged on the Fed's interpretation of the 2010 financial reform law, which required the agency to establish price caps for debit card transactions.

The law states that the Fed should consider the incremental costs associated with each debit-card transaction when establishing a cap on fees, but it should not consider other costs that are not specific to any individual transaction.

The central bank initially proposed to cap such fees at no more than 12 cents per transaction. But after lobbying by banks, the Fed raised the cap to around 24 cents to account for more costs than were covered by its initial plan.

In his ruling, Leon concluded that many of the costs that the Fed considered in establishing the 24-cent cap were not incremental costs associated with each transaction, and that Congress had barred the Fed from taking other costs into account.

"Ultimately, the board asserts that it was given broad discretion to fill statutory gaps in establishing the interchange transaction fee standard," the judge wrote. "But even if this were true, which it is not, such discretion does not give the board the authority to ignore the expressed will of Congress."

The judge's decision went beyond debit card price caps, also overturning the Fed's rules on the routing of debit card transactions.

Under the current rules, merchants must be given the choice of routing debit card transactions over at least two unaffiliated networks. But that can mean one network for PIN debit transactions and another for signature debit transactions. So if the customer selects a PIN debit transaction, the merchant may not have a choice of networks.

But the judge concluded that the law requires more competition, and that merchants must be given the choice of using two unaffiliated networks for each transaction, regardless of whether the customer punches in a PIN or signs a receipt.

That finding drew praise from the retail industry, which called it a boon to competition. But the stiffer routing requirements may pose technological hurdles, according to David Stein, a director at the banking consulting firm Promontory Financial Group.

He noted that Visa (NYSE: V) and MasterCard (MA) currently run the only signature debit networks, and questions whether those two systems could cope with potentially unpredictable swings in volume. He also said that the entire logic of the routing system would have to be changed to allow for Visa cards to be processed over MasterCard's network, and vice versa.

"I don't want to say that they are insurmountable technological obstacles," said Stein, a former lawyer at the Fed. "But they could be very costly and disruptive to implement."

Both Visa and MasterCard declined to comment on the judge's ruling.

Some of the biggest winners from the decision are likely to be retailers whose customers make relatively inexpensive purchases. Examples include convenience stores and newsstands.

Under the Fed's current rules, merchants actually pay significantly higher swipe fees on small-ticket purchases than they did prior to the adoption of price caps, the judge concluded.

That's because charges that were previously calculated as a percentage of the retail purchase price are now being imposed as flat fees. For a $1 purchase, swipe fees that might have totaled less than a dime under the old system could now be higher.

"Debit fees on low dollar transactions, which increased under the current rule, will now have to be reasonable, as the law requires," the Merchants Payments Coalition, a group whose members include convenience stores and other retailers, said in a news release.

For now, all eyes are on the Fed, as it ponders whether to appeal the district court's decision. The American Bankers Association and others are already urging it to do so.

"I think this is a pretty draconian decision," said Oliver Ireland, a lawyer at Morrison Foerster who frequently represents banks, "and we would hope that the Board would appeal it."

Leon has scheduled an Aug. 14 status conference, at which point the next steps in the case will likely be clearer.