OAKLAND -- Drugstore giant Walgreens must pay more than $16.5 million in damages as part of a lawsuit settlement in which the Illinois-based company was accused of illegally dumping pharmaceutical and biohazardous wastes throughout California.

The settlement agreement reached in Alameda County Superior Court ends a joint lawsuit filed by district attorneys representing more than half of the counties in the state, including Alameda County.

The lawsuit claimed that Walgreens employees were illegally dumping pharmaceutical and biohazardous waste into regular trash bins rather than sending the waste to authorized disposal sites.

Walgreens spokesman Jim Graham said Thursday that the company admits no wrongdoing and settled the case "to avoid the time and expense of protracted litigation."

Graham said Walgreens has invested millions of dollars since 2007 to develop and implement "a comprehensive waste management program" at all of its California stores.

"All hazardous materials are shipped by licensed environmental haulers to a hazardous waste disposal facility, where they are incinerated," Graham said. "We are continuing to strengthen our programs to ensure that these procedures are properly followed."

The California Department of Toxic Substances Control discovered the illegal dumping and other violations of state laws during a three-year investigation that found the company also mishandled confidential medical records. The Alameda County District Attorney's office found the same violations at Walgreens' 34 sites in the county.

Under the agreement, Walgreens must pay $16.5 million in penalties and costs and fund environmental projects that will further consumer protection and environmental enforcement in California.

In addition, Walgreens agreed to create new procedures for its employees including having hazardous waste segregated in labeled containers.

The lawsuit was filed by district attorneys of Alameda, San Joaquin, Solano, Monterey, Riverside and Yolo counties and the city attorney of Los Angeles.