(Reuters) - Visa Inc, Mastercard Inc, and a number of U.S. banks on Tuesday agreed to pay $6.2 billion to settle a long-running lawsuit brought by merchants over the fees they pay when they accept card payments.

Visa and Mastercard previously reached a $7.25 billion settlement with the merchants in the case, but that deal was thrown out by a federal appeals court in 2016 and the U.S. Supreme Court last year refused to revive it.

The deal had been the largest all-cash U.S. antitrust settlement, although its value shrank to $5.7 billion after roughly 8,000 retailers opted out.

The card issuers named in the class-action lawsuit include JPMorgan Chase & Co, Citigroup and Bank of America.

The lawsuit, brought on behalf of about 12 million retailers and dating back more than a decade, accuses the credit card companies of violating federal antitrust laws by forcing merchants to pay swipe fees and prohibiting them from directing consumers toward other methods of payment.

Slideshow ( 2 images )

In rejecting the earlier settlement, which was opposed by retailers including Amazon.com Inc, Costco Wholesale Corp and Walmart Inc, a federal appeals court found that the accord was unfair because some retailers would receive little or no benefit.

The card companies have already paid $5.3 billion and will now pay an additional $900 million.

Mastercard will pay an additional $108 million from funds set aside in the second quarter, the company said reut.rs/2OA2V0i.

Visa’s share represents around $4.1 billion, which the company expects to pay using funds previously deposited with the court, and from a litigation escrow it set up on June 28.

The settlement must still be approved by a court.