RIVERSIDE — A Riverside County judge has ordered Best Buy Stores to pay nearly $900,000 and to institute a special discount program to settle a lawsuit alleging the company charged more than advertised prices at some California stores.

The district attorneys of Riverside, San Diego and Los Angeles counties filed the case this week after weights and measures officials documented overcharges during inspections.

On Friday Judge Daniel Ottolia ordered the company to pay $600,000 in penalties, about $175,000 in costs and $100,000 in restitution.

For the next five years the California stores must offer customers $3 off the lowest advertised price of an item if they are overcharged at checkout.

Best Buy spokesman Jeffrey Shelman said in a statement that the company apologizes for the tiny fraction of items with pricing errors.