BP has agreed to pay $7 million in damages and other costs to settle a class action lawsuit brought by several law firms after it sold bad gasoline to more than 575 retail outlets in four states last August, according to a release by Cohen & Malad, LLP, a firm representing plaintiffs.

The 4.7 million gallons of bad gasoline were sold at various outlets in Indiana, Illinois, Wisconsin, and Ohio and left some motorists filling up with the affected fuel with damaged engines and costly repair bills.

BP had worked quickly last August to identify the gas stations that sold the bad gas, and had set up a website that motorists could see what gas stations had sold the tainted gasoline.

According to the release, BP identified a “process upset” as the source of the gasoline contaminant. It stated that higher than normal levels of a hydrocarbon polymer passed through the refinery unit, contaminating the gas that was distributed to the affected retail outlets.

“Finally, through the court system, has BP agreed to fully and fairly compensate consumers who bought their adulterated product. It’s been a long road but we’re pleased with the result,” stated Irwin Levin of Cohen & Malad, LLP.

Will Riley of Price Waicukauski & Riley, LLC added "I am pleased that the legal system was able to set this situation right for Hoosiers, and those in the surrounding states."

News of the settlement comes just days after BP had announced it was joining the Top Tier gasoline program, a program that Top Tier says "is about an engine cleanliness and performance specification," a program that BP was not part of when it recalled its bad gasoline in 2012.