CVS agreed to pay $6.3 million to resolve a civil complaint brought by prosecutors across the state — including San Diego County’s — alleging the pharmacy chain illegally overcharged customers, it was announced Friday.

The lawsuit claimed CVS charged customers higher prices on “an array of products” than their lowest advertised or posted price in 24 of its 81 stores in San Diego County, as well as others in California.

The judgment requires CVS to implement a Price Accuracy Program for five years, which involves store audits and a computer price-tracking database.

CVS’s Scan Right Guarantee Program, which provides overcharged customers with compensation, will increase its remedy from $4 to $5.

Along with $6 million in civil penalties, CVS will pay $100,000 to a nonprofit to fund future investigations and $160,563.82 in investigative costs.

The lawsuit was filed in Sonoma County Superior Court in conjunction with the District Attorney’s offices of San Diego, Los Angeles, Orange, San Bernardino, Santa Cruz and Ventura counties.