Three major drug distributors are in talks to pay $18 billion to settle sweeping litigation brought by state and local governments blaming them for fueling the opioid crisis, people familiar with the discussions said, paving the way for a broad resolution to lawsuits that have shaken the pharmaceutical industry.

The three distributors—McKesson Corp., AmerisourceBergen Corp., and Cardinal Health Inc.—would collectively pay $18 billion over 18 years under the deal currently on the table, the people said. Johnson & Johnson...