WASHINGTON (Reuters) - Volkswagen AG VOWG_p.DE has agreed to spend more than $1.2 billion to compensate its 650 U.S. dealers for their losses from the German automaker's diesel emissions scandal, two sources briefed on the matter said on Thursday.

Volkswagen cars are parked outside a VW dealership in London, Britain November 5, 2015. REUTERS/Suzanne Plunkett/File Photo

The company and a lawyer for VW dealers announced a tentative settlement at a court hearing in San Francisco, but declined to disclose the amount. The settlement, which followed talks that began in May, came as a judge ordered VW to move quickly to decide whether to fix or buy back 85,000 3.0 liter luxury vehicles with polluting engines.

The settlement includes $1.2 billion in payments for the reduction in value of VW dealerships and additional payments for vehicles that could not be sold, the sources said. VW has also agreed to continue to make certain incentive payments to dealers, they said.

“We believe this agreement in principle with Volkswagen dealers is a very important step in our commitment to making things right for all our stakeholders in the United States,” said Hinrich J. Woebcken, chief executive of VW’s North American region.

The dealer settlement means VW has agreed to spend at least $16.5 billion in total in the United States to address emissions issues, but by no means is out of the woods. Volkswagen still faces billions of dollars in potential civil and potential criminal U.S. fines for violating emissions laws, as well as a potential costly buy-back of vehicles equipped with 3.0 liter diesel engines.

VW has admitted it installed improper software that deactivated pollution controls on more than 11 million diesel vehicles sold worldwide. In June, it agreed to pay up to $15.3 billion to buy back up to 475,000 vehicles and address claims by federal regulators and 44 U.S. states.

VW’s U.S. dealers have been barred from selling new diesel vehicles for nearly a year.

The agreement in principle must still be approved by the court. Under the settlement, Volkswagen agreed to repurchase unfixable, used 2.0 liter diesel vehicles on dealers’ lots under the same terms of a consumer buy-back, said Steve W. Berman, a Seattle lawyer representing dealers at the hearing.

The deal would help “heal the wounds between Volkswagen and the dealers,” who “like consumers, have been financially hurt here,” he said. “They have cars on their lots they can’t sell, their franchise value has gone down and they’ve invested millions in these Volkswagen franchises.”

As a result of the scandal, the automaker’s U.S. sales are down 13.6 percent in 2016 after falling 5 percent last year.

VW had previously agreed to buy back 475,0000 vehicles equipped with 2.0 liter engines at a cost of up to $10.03 billion.

Judge Charles Breyer of the U.S. District Court for the Northern District of California ordered Volkswagen and federal regulators to start settlement talks to resolve the fate of 85,000 3.0 liter diesel vehicles that could include a buy-back offer for those Porsche, Audi and Volkswagen vehicles.

Buying the expensive larger cars and SUVs sold since 2009 could cost VW billions of dollars.

But VW lawyer Robert Giuffra said the automaker believes it can fix those vehicles. “We’ve got to persuade the government that we have a fix,” he said, adding that the issue is extremely complex and involves “two million lines of code.”

Breyer set a Nov. 3 hearing for an update on the status of the talks and emphasized the urgency of resolving the issue. He said he wanted to ensure “a strong sense of reality” in finding a solution, calling it “intolerable” that the polluting cars remain on U.S. roads.

Breyer said VW will be forced to repair the polluting vehicles, buy them back or offer both options.

VW must submit by late October its specific plans to fix the 3.0 liter vehicles, which it said include a mix of software upgrades and emissions equipment modifications.

Not all details of how the settlement fund will be divided among the dealers have been resolved. The settlement is worth about $1.8 million on average per dealer, but Berman said in a statement that dealer payouts “under the proposed settlement will depend on the size of the dealership and the size of the market it serves, among other factors.”

VW and the dealers told Breyer they plan to file details of the agreement by the end of September.

The U.S. Justice Department and Environmental Protection Agency have not yet reached a deal with Volkswagen on fines as part of a separate settlement that could lead to an outside monitor overseeing VW’s compliance with U.S. laws.

Reuters reported that VW held preliminary talks this month with the Justice Department to settle outstanding issues. It also agreed to open settlement talks with four states that have sued over environmental harms.