A federal judge in San Francisco gave final approval Monday to a $1.67 billion settlement for 644 Volkswagen franchise dealerships affected by the automaker’s diesel emissions scandal.

Volkswagen has admitted its diesel engines were programmed with software designed to defeat emissions control testing.

The dealerships will receive average settlements of $1.85 million.

Some 600,000 Volkswagen and Audi diesel vehicles in the United States, model years 2009 through 2015, were revealed to have a “defeat device” to cheat emissions tests by producing regulation-compliant results during testing but then giving off emissions at much higher levels during normal operation.

U.S. District Judge Charles Breyer said the settlement compensates the dealerships for the devaluation of their franchises as a result of the scandal. Half of the settlement will be paid upfront and the rest will be paid out in 18 monthly installments.

The settlement relieves dealerships of requirements to make costly capital improvements for two years and establishes guidelines for resolving inventory issues with diesel cars that have been stuck on dealer lots since the scandal broke.

The settlement also requires owners of affected vehicles be offered three appointment dates for fixing the problem.

Federal prosecutors filed criminal charges against six Volkswagen executives earlier this month for their roles in the scandal. Those charged include a former head of development and the head of engine development. One of the executives, Oliver Schmidt, who was in charge of compliance, was arrested in Florida; the other five are in Germany.

The company formally pleaded guilty to charges of conspiracy to commit wire fraud and to violate the Clean Air Act, customs violations and obstruction of justice, and faces $4.3 billion in criminal and civil penalties.

The company already has settled suits with car owners totaling $14.7 billion.

“Volkswagen knew of these problems,” Attorney General Loretta E. Lynch said at a news conference in Washington Jan. 11. “When regulators expressed concerns, Volkswagen obfuscated. And they ultimately lied.”

Investigators say more indictments are possible.