CVS (CVS  ) and Walgreens (WBA  ) have agreed to pay roughly $5 billion each to state and Native American tribal governments in the largest settlements paid by a pharmacy allegedly involved in fueling the opioid epidemic. The settlement agreement is not an admission of fault, and no money will go directly to the individuals affected by the crisis.

The settlements were filed by both pharmacies, but they will still need to receive approval from a majority of plaintiffs.

Over the past two decades, more than half a million deaths have been linked to opioid overdoses in the U.S., with recent years seeing an average of 80,000 individuals killed by opioid overdoses annually. According to the suits filed against the pharmacies, the high number of scripts being filed in certain areas should have been flagged as suspicious.

These settlements could be one of the last major payouts related to the opioid epidemic, but there's still one big player left. Walmart (WMT  ) has been involved in prior litigation with Walgreens and CVS regarding opioids, and it's still in talks to settle government lawsuits. According to a New York Times source, Walmart has agreed to pay $3.1 billion to settle the claims, but that deal has not been confirmed.

Over the course of a decade, CVS has agreed to pay $4.9 billion to local governments and another $130 million to reservation governments. For Walgreens, the agreement is to send $4.8 billion to local governments and $155 million to tribal governments over the next fifteen years. These figures could vary depending on how many parties agree to the settlement.

For CVS and Walgreens, the hope is that this agreement will be the end of their role in the process, but there is a possibility that one of the governments involved in the settlement could refuse to accept the agreement and continue to pursue its own case separately.

"We are pleased to resolve these longstanding claims and putting them behind us is in the best interest of all parties, as well as our customers, colleagues and shareholders," CVS chief policy officer and general counsel, Thomas Moriarty, is quoted in a statement. "We are committed to working with states, municipalities and tribes, and will continue our own important initiatives to help reduce the illegitimate use of prescription opioids."

The settlement money is meant to be spent on efforts to combat the opioid epidemic, like expanding addiction programs, establishing prevention plans, and providing overdose treatments.

"As one of the largest pharmacy chains in the nation, we remain committed to being a part of the solution," Walgreens wrote in a statement, "and this settlement framework will allow us to keep our focus on the health and wellbeing of our customers and patients, while making positive contributions to address the opioid crisis."

While they are higher than most other opioid payouts, CVS and Walgreens's settlements are still smaller than deals made by drug companies in 2021. Purdue, the maker of OxyContin, has agreed to pay $6 billion, and Johnson & Johnson (JNJ  ) and the other drug's distributors paid $25 billion. In total, settlements related to the opioid crisis have surpassed $50 billion.

"One by one, we are holding every player in the addiction industry accountable for the millions of lives lost or devastated by the opioid epidemic," said the Attorney General of Connecticut, William Tong, in a statement. "The companies that helped to create and fuel this crisis must commit to changing their businesses practices, and to providing the resources needed for treatment, prevention and recovery."