Walmart on Tuesday announced it agreed to a $3.1 billion nationwide settlement designed to resolve all the potential state lawsuits it faces for its alleged role in fueling the opioid epidemic.

The settlement framework, subject to the review and approval of involved states, would address years of litigation for the retail giant at the state, local, and tribal level regarding the actions of its pharmacists and their contributions to the opioid epidemic. Walmart continues to deny all related allegations but said it believes the settlement is “in the best interest of all parties and will provide significant aid to communities across the country in the fight against the opioid crisis.”

“Walmart strongly disputes the allegations in these matters, and this settlement framework does not include any admission of liability,” the company said in a news release. “Walmart will continue to vigorously defend the company against any lawsuit not resolved through this settlement framework.”

Walmart and fellow pharmacy retailers CVS and Walgreens were ordered in August to pay a total of approximately $650.6 million over 15 years to two Ohio counties after a jury concluded the companies “engaged in intentional and/or illegal conduct” in a case related to the opioid epidemic. The case was the first to levy damages against retail pharmacy chains following a jury trial and foreshadowed the litigation risks the companies would continue to face as other opioid-related trials played out.

CVS and Walgreens earlier this month each announced nationwide settlement frameworks of their own to resolve their opioid-related liability, agreeing to pay approximately $5 billion each.

Settlement details: The agreement includes court-required improvements to how Walmart pharmacies handle opioids, including oversight to prevent fraudulent prescriptions and flag suspicious prescriptions, according to a press release from the Office of the New York Attorney General. Walmart must implement a controlled substance compliance program (CSCP) and chief controlled substance compliance officer.

Other CSCP requirements include establishment of a hotline, mandatory training, and red flag monitoring.

The settlement framework is expected to receive the approval of the required 43 states by the end of the year. If so, local governments will be allowed to join the deal in the first quarter of 2023.