San Francisco: German automaker Volkswagen has agreed to fix or buy back nearly half a million diesel cars sold in the US but fitted with illegal emissions software. The settlement between Volkswagen and US Environmental Protection Agency, the state of California and consumers was announced on Thursday by US District Judge Charles Breyer at a hearing here, Xinhua news agency reported. Breyer said the deal would allow consumers to sell their cars back to Volkswagen or get them repaired to meet the legally required emissions levels. It also includes "substantial compensations" for consumers and investment on clean technologies to offset excess emissions. The affected cars are VW's 2-litre diesel passenger vehicles sold in the US between 2009 and 2015, during which the company used a "defeat device" to cheat on emissions tests and tried to cover it up. Details of the settlement were not disclosed. Breyer set July 21 as the deadline for Volkswagen to settle with all the parties the specifics of the plan, including the amount of fines and compensations it should pay. Hundreds of class-action lawsuits have been filed against the German automaker following its admission of emissions cheating last September. It also faces hefty US government penalties for violating pollution standards. Analysts estimate that the cost of the final deal would far exceed the amount of money Volkswagen has set aside for the global costs from the scandal, which is $7.6 billion. Worldwide about 11 million vehicles are involved in Volkswagen's emissions cheating scandal and nearly 600,000 of them are in the US. Earlier this year, the California Air Resources Board rejected the recall plan submitted by Volkswagen for 2-litre diesel cars sold in the state between 2009 and 2015.