A federal judge on Friday gave Visa and MasterCard the go-ahead on a $5.7 billion class-action settlement to resolve merchant complaints over the fees they are charged each time a customer swipes a credit or debit card.

The ruling comes after years of litigation and ushers in the largest private antitrust settlement in history. Yet it is not enough to quell the anger of retailers, who say the agreement does not prevent the credit card giants from imposing higher fees with impunity.

“We are very disappointed that this deeply flawed settlement has been approved,” Mallory Duncan, general counsel at the National Retail Federation, said in a prepared statement. “It is not supported by the retail industry and would do nothing to reduce swipe fees or keep them from rising in the future.”

The trade group is considering appealing and has the backing of several retail organizations, including the National Association of Convenience Stores and National Community Pharmacists Association, that say the deal will not change the fighting between merchants and card companies.

Others involved in the case are more confident that the deal could result in a win for shoppers, who might see lower prices for products depending on how they choose to pay.

“It will reduce the fees and overall prices that consumers pay, which is good for merchants and consumers,” said Patrick J. Coughlin, one of the merchants’ attorneys and senior trial counsel at Robbins Geller Rudman & Dowd. “There will be more transparency in the pricing.”

U.S. District Judge John Gleeson approved the settlement in a written order.

Retailers first sued Visa and Mastercard in 2005 over “swipe fees,” also known as interchange fees. Card processors, such as Visa and MasterCard, set swipe-fee rates, but merchants pay banks the fee each time a customer uses plastic. Swipe fees are typically 2 to 5 percent of the purchase price.

Merchants have argued that they have limited power to negotiate the amount of the fees, which cost them and their customers about $30 billion a year, according to the National Retail Federation. They have also accused credit card companies of barring them from steering shoppers to cheaper forms of payment.

Financial firms contend that they are charging retailers for providing a service that helps their businesses. The government stepped into the fray two years ago, when the Federal Reserve placed caps on swipe fees for debit cards but not credit cards.

In July 2012, attorneys representing merchants nationwide reached a $7.2 billion settlement that has since tumbled to $5.7 billion as 8,000 merchants, including Amazon and Wal-Mart, bowed out of the deal. Those dissenters say the deal forces merchants that accept Visa or MasterCard to waive their right to sue the companies over swipe fees.

The settlement includes cash payments to merchants across the country. It also allows retailers to charge shoppers extra if they choose to use MasterCard or Visa, a practice known as surcharging. Critics of the deal say retailers are unlikely to take advantage of the surcharging for fear of driving shoppers to competitors that do not engage in the practice.

For the credit card companies, the approval of the settlement will allow them to cast aside a tremendous legal headache. Two years before the class action lawsuit, Visa and MasterCard settled a similar case over the card fees with another group of retailers.

“We have realized a significant achievement in our efforts to resolve the long-standing legal differences between merchants and the payments industry,” Charlie Scharf, chief executive of Visa, said in a statement. “We are confident that through this agreement we have opened the door to new opportunities for collaboration with our merchant clients.”