In an effort address a scandal that has affected both its business operations and its reputation, Volkswagen AG announced a deal in which it will buy back or fix up to 500,000 vehicles that are equipped with diesel engines. The deal was negotiated between VW and the U.S. Justice Department, Environmental Protection Agency, Federal Trade commission, the state of California and lawyers representing car owners in class action civil lawsuits.

In a hearing conducted in a San Francisco courtroom, Federal Judge Charles Breyer outlined the terms of the agreement. A deadline of June 21 was also set for parties to provide final details and respond to outstanding questions. Among the remaining concerns is whether VW will be permitted to sell vehicles that it repurchases and how it plans to fix up to 90,000 Porsche, Audi and VW vehicles that make use of six-cylinder diesel engines that have failed to meet U.S. emissions standards.

Judge Breyer indicated that the terms of the settlement include VW’s offer to repurchase 482,000 vehicles equipped with 2.0L engines, fix the vehicles subject to additional testing and for it to cancel outstanding leases. Also included in the agreement are stipulations for VW to commit to a fund for environmental remediation and to provide compensation for vehicle owners to sell back or repair their cars and SUVs.

Financial details of the settlement were not disclosed, but industry analysts estimate that it could cost VW at least $10 billion.