The companies either did not respond to messages or declined to comment. The distributors have said they were simply delivering medication that was approved by the Food and Drug Administration and prescribed by doctors.

Pennsylvania, North Carolina, Tennessee and Texas are leading the settlement talks for the states, along with lawyers for thousands of cities and counties whose cases are in federal court.

According to people familiar with the talks, the combined value of the deal breaks down as follows: $20 billion to $25 billion in cash to be divided among the states and localities to help pay for health care, law enforcement and other costs associated with the epidemic; and another $25 billion to $30 billion in addiction-treatment drugs, supplies and delivery services.

Many details are still being debated, including the timetable for when the money would be paid, people familiar with the negotiations said. Some state and local governments wanted more details about how the companies calculated the total dollar figures on services and addiction-treatment drugs.

Whether the amount will be considered sufficient by all the plaintiffs remains to be seen. A new report by the Society of Actuaries projects that the costs related to the opioid epidemic — including health care, child and family assistance programs, criminal justice activities and lost wages — will hit $188 billion in 2019 alone.

“It’s not an accident these offers are coming out on the eve of trial,” said Abbe R. Gluck, a professor of health policy and law at Yale Law School. “But I think the question will be if this number is going to be enough to get a sufficient number of local governments to sign on.”

People familiar with the talks said that one sticking point in the negotiations is how much money will go toward attorneys’ fees for the private lawyers who represent governments in the overwhelming majority of cases and work on contingency.