Volkswagen cars are loaded in a delivery tower at the company's plant in Germany.Fabian Bimmer / Reuters

Volkswagen has agreed to repair or buy back nearly 600,000 vehicles it sold in the United States that were equipped with illegal software that evaded U.S. emissions standards.

A U.S. district judge in California announced the agreement Thursday between the German automaker and the U.S. Justice Department, the Environmental Protection Agency, and the California Air Resources Board. The decision comes six months after the EPA and the California agency discovered Volkswagen had manipulated engines of its “clean diesel” cars so they released emissions at EPA-approved levels in test settings but spewed 40 times the levels allowed while on the road. Volkswagen has admitted to selling 11 million vehicles with this software worldwide since 2009.

The company said Thursday:

Volkswagen is committed to earning back the trust of its customers, dealers, regulators and the American public. These agreements in principle are an important step on the road to making things right.

Volkswagen has been unable so far to offer fixes to the cars, and buying them back could cost the company billions of dollars, according to USA Today. The agreement also requires Volkswagen to invest in “green automotive” initiatives.

The deal means Volkswagen will avoid a trial in the U.S., but its troubles are far from over. The company reported its first quarterly loss in at least 15 years last October. It faces criminal investigations in the United States, Germany, and France, and has poured billions of dollars into efforts to repair its damaged global image.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.