Volkswagen has agreed to pay its U.S. dealers up to $1.2 billion to compensate them for losses they said they suffered as a result of the company’s emissions cheating scandal, according to a settlement agreement filed Friday in federal court in San Francisco. Under the terms of the deal, dealers can opt out and pursue their own lawsuits against Volkswagen. A judge must to approve the settlement before it can go into effect. Volkswagen previously reached an agreement with attorneys for car owners. That deal calls for it to spend up to $10 billion buying back or repairing about 475,000 vehicles involved in the cheating and paying their owners an additional $5,100 to $10,000 each. Details about the vehicle repairs have not been finalized. Attorneys for vehicle owners said in a court filing Friday that more than 311,000 people have registered for the deal and fewer than 3,300 people have opted out. “There is resounding support for this consumer class settlement and the substantial benefits it provides,’’ Elizabeth Cabraser, lead attorney for Volkswagen owners, said in a statement. The settlement also includes $2.7 billion for unspecified environmental mitigation and an additional $2 billion to promote zero-emissions vehicles. U.S. District Judge Charles Breyer gave the deal preliminary approval in July, and he is expected to make a final decision October 18. The deal does not cover about 85,000 more-powerful Volkswagens and Audis with 3-liter engines also caught up in the emissions scandal.