SAN FRANCISCO — A federal judge on Thursday morning said that Volkswagen A.G. has reached an agreement with federal and California state authorities that will compensate car buyers who were affected by the German automaker’s diesel-emissions scandal and attempt to address the environmental damage caused by the vehicles.

The settlement impacts approximately 480,000 two-liter-engine cars. VW owners will have the option of Volkswagen buying back their vehicles or having them repaired to address their excess emissions, subject to government approval pending further testing. People who leased the cars will be able to cancel the lease, U.S. District Judge Charles Breyer of the Northern District of California said.