A federal judge on Thursday said Volkswagen has agreed in principle to repurchase or fix cars sold by the German automaker that exceed pollution limits.

The accord, announced by U.S. District Court Judge Charles Breyer in San Francisco, could mean that VW avoids a trial. Breyer had set Thursday as a deadline for the company to come up with a plan to resolve issues involving cars that violate U.S. emissions standards.

The scandal came to light in September, when the Environmental Protection Agency said VW sold nearly half a million diesel cars with "cheat" software intentionally designed to bypass air pollution controls. The ensuing fallout had Martin Winterkorn stepping down as VW's CEO and the automaker's top U.S. executive, Michael Horn, resigning in March.

Get Breaking News Delivered to Your Inbox

The actual amount to be paid to consumers was not revealed, but Breyer called it "substantial compensation," said Thomas Young, an attorney who is representing a Florida county in a suit against VW who listened to the hearing by phone.

The EPA's assistant administrator for enforcement, Cynthia Giles, said in September that VW could face up to $18 billion in fines, or $37,500 for each vehicle. Most experts expect the figure will be far below that number.

"This matter is by no means resolved, since penalties and fines still loom," said Rebecca Lindland a senior analyst at Kelley Blue Book, an automotive research company that calculates the cost of buying back all the cars in the U.S. at $7.3 billion. "We don't know yet the full financial impact on Volkswagen."

VW also faces fines overseas, with more than 10 million cars in Europe also affected by the company's cheating.

"Is the beginning of the end, or the end of the beginning?" said Jean Ergas, an adjunct assistant professor at the NYU School of Professional Studies and chief economist at Tigress Financial Partners, who added that he believes the saga is still in its early stages. "We're looking at reports of $50 billion by the time the whole thing is finished. This is more expansive than the company has bargained for."

VW's allocation of $7 billion to contend with the emissions scandal will prove insufficient in the long run, Ergas added.

"Volkswagen is committed to earning back the trust of its customers, dealers, regulators and the American public," the company said in a statement. "These agreements in principle are an important step on the road to making things right. As noted today in court, customers in the United States do not need to take any action at this time."

Thursday's deal involves 480,000 2-liter diesels, which will either be repurchased by Volkswagen or fixed. Leased cars can be returned. Another roughly 90,000 cars, including 3-liter diesels Porsche and Audi branded vehicles, are still being discussed.

Breyer set a June 21 deadline for the details to be hammered out.

The U.S. Public Interest Research Group, which came out with the "Make VW Pay" campaign not long after the emissions cheating was announced, said the proposed settlement appears to have all the elements that it should, but the "devil will be in the details."

"In the meantime, it's worth noting that further delay means that these polluting cars remain on the road -- emitting up to 40 times the allowable level of pollution -- for even longer," the non-profit public interest group said in a statement.

Beyond the cost of compensating consumers, Volkswagen still faces billions in potential fines by the EPA and the Federal Trade Commission for deceptive advertising. The company is also being sued by several states and local governments, while the U.S. Department of Justice said it is continuing an investigation into VW's conduct.

"This agreement in principle addresses one important aspect of the Department's pending case against VW, namely what to do about the 2-liter diesel cars on the road and the environmental consequences resulting from their excess emissions," the agency said in a statement after Thursday's agreement was announced.

Thursday's agreement does not resolve claims by states, New York Attorney General Eric Schneiderman said in a statement. A multi-state coalition that includes New York, Connecticut, Massachusetts, Oregon, Tennessee and Washington "continues to vigorously investigate Volkswagen's misconduct, and will aggressively pursue the recovery of substantial penalties and other appropriate relief," Schneiderman said.

Whatever VW's ultimate legal bill stemming from the scandal, Young expects the company to recover. "They are too important to Germany and their local economy," said the lawyer, who is representing Hillsborough County, Florida, in a suit against VW for violating local ordinances dealing with emission control devices. "They are too big to fail."

In the U.S., however, the company could be looking at a lengthy process in terms of its public image.

"Strong brands are resilient, and VW is one of those brands that had a good standing with the American public for a long time," Erich Joachimsthaler, founder and CEO of Vivaldi Partners Group, said in an emailed statement. "But it will take years before VW fully recovers."

The vehicles and model years affected by the agreement.