The U.S. Justice Department announced Monday that Walgreens had agreed to pay $300m to settle allegations by U.S. prosecutors that it filled millions of prescriptions for controlled substances and opioids illegally.

According to the terms of the contract, the money plus 4% annual interest will be paid over six years. Walgreens will owe an additional $50 million to the United States if it sells, merges, or transfers before fiscal year 2032.

Walgreens stated in a Friday filing to the U.S. Securities and Exchange Commission that this case was the “last anticipated major opioid regulatory issue” and it had settled the matter without admitting any wrongdoing, “to avoid the costs and uncertainty of continuing litigation.”

In its January lawsuit, the government alleged that Walgreens filled prescriptions despite “red flags”, indicating they were illegal. This was in violation of the Controlled Substances Act. The government also claimed that Walgreens violated the False Claims Act by requesting reimbursement for prescriptions from federal health programs like Medicare.

Walgreens was among the drug producers, distributors, pharmacists, and others who collectively agreed in recent years to pay around $50 billion in settlements of lawsuits and investigations brought by state and local governments accusing the companies and individuals of fueling a deadly epidemic of opioid addiction in the U.S.

Walgreens has agreed to settle thousands of lawsuits filed by local and state governments that accuse the company of fueling America’s opioid epidemic. The settlement will be paid in 15 years, up to a maximum of $5.52 billion.

According to the U.S. Centers for Disease Control and Prevention, nearly 727,000 deaths due to opioid overdoses occurred between 1999 and 2022.