Visa Inc., MasterCard Inc. and some large banks agreed to pay scores of retailers—from giant Publix Supermarkets Inc. to an interior-design store in Minnesota—more than $6 billion to settle a long-running lawsuit, in a pact that also permits merchants to charge more to customers who pay with credit cards.

The settlement is a victory for retailers, which will get more control over how people pay, and removes a legal threat for the major card companies.

It...