Volkswagen will settle its emissions scandal case for $14.7 billion, the largest payout by an automaker to consumers in U.S. history, in an agreement set to be formally announced Tuesday morning, according to two people familiar with the matter.

More than $10 billion of the settlement will go to fix or buy back 475,000 Volkswagens with two-liter diesel engines that were programmed to turn off emissions measurement data outside of laboratory settings, the people said, speaking on condition of anonymity because the deal had not yet been announced. Those engines spewed 40 times the legal limit of harmful nitrogen oxides.

Another $2.7 billion will go into an Environmental Protection Agency trust fund for environmental remediation, and the German automaker will spend $2 billion more on American clean energy technology.

Nearly 40 state attorneys general are also set to announce resolutions with Volkswagen that could bump the total settlement valuation to more than $15 billion.

A criminal investigation into the 2015 “diesel-gate” scandal, one that involved 11 million vehicles worldwide, is pending.

“This is not a slap-on-the-wrist kind of thing,” said Erik Gordon, a professor at the University of Michigan Ross School of Business. “It’s a big financial setback and a big reputational setback. This is more than an annoyance for VW. It’s going to force VW to do some triage for its future.”

Car owners will have the option of selling their vehicles back to VW at pre-scandal prices or to have the emissions software fixed free of charge. Aside from that compensation, those drivers are also eligible to receive between $5,100 and $10,000 in the settlement.

Consumers who sold or traded in their vehicles are also entitled to compensation, even if the current owners are also being compensated.

The buyback and fix program runs through Dec. 1, 2018. By then, the settlement requires Volkswagen to have replaced or repaired 85 percent of the affected cars or pay hundreds of millions of dollars more in federal fines.

Once hailed as a leader in efficient “German engineering,” VW’s reputation has gone through the ringer after the massive scandal and settlement, industry analysts say. And the monetary penalties, with more to come from the Justice Department and European regulators, have dealt a sizable blow to one of the auto industry’s most admired brands.

“The (public relations) piece is such a huge piece, especially because people relied on these ‘green’ cars and now they feel cheated,” said Carl Tobias, a professor of law at the University of Richmond in Virginia. “I think the pressure was so intense that they weren’t paying attention or cut corners or cheated. You just can’t do that. It won’t fly in the U.S. with our consumers and our agencies. I just don’t think VW reckoned with that or did not take it seriously until it was too late.”

The settlement is the latest massive fine imposed by federal environmental and safety regulators on big automakers. In 2012, Toyota paid $1.1 billion after its gas-pedal recall. In 2015, General Motors agreed to pay $900 million after an ignition-switch defect. Takata has yet to reach a settlement with regulators over its massive airbag recall.

Stephanie Walkenshaw, of Denver, purchased her 2014 Jetta SportWagen TDI months before news of the emissions scandal broke. Until recently, after trying to claim some remittance from Volkswagen, she said she’d have preferred to keep her car after getting it fixed.

Now, she says, she’ll never buy a VW again.

“I thought VW played on people’s good intentions, and that’s one of the worst things you can do,” she said. “I wanted a car that had power but what was also good for the environment. They preyed on exactly what I wanted.”