The lawsuit alleged that more than 600 Walgreens stores in the state unlawfully handled and disposed of pesticides, paints and other hazardous materials for more than six years.
The judgment is the result of a civil enforcement lawsuit filed in June by the district attorneys in several counties including Riverside.
The settlement also resolves allegations that Walgreens unlawfully disposed of customer records containing confidential medical information.
In addition to the $16.57 million, the settlement agreement requires Walgreens to fund supplemental environmental projects in California. The chain has also been ordered to retain hazardous waste in separate, labeled containers to minimize exposure and also take steps to preserve the confidentiality of customers' medical information.
Walgreens spokesman Jim Graham said the company did not acknowledge any wrongdoing and settled the case to avoid protracted litigation.
He said Walgreens ships all hazardous materials are shipped to a hazardous waste disposal facility, where they are incinerated.
The Associated Press contributed to this report.