A BP Plc unit will pay $102 million to settle a lawsuit accusing the company of overcharging California for natural gas, the state’s attorney general said.

The accord spared BP from facing a jury trial that was scheduled to start this week in San Francisco. A lawyer for the ex-employee who initially filed the complaint as a whistle blower in 2012 called it the largest settlement of its kind involving an oil company in state history.

“BP thought it could get away with providing false and misleading information in order to line its own pockets,” California Attorney General Xavier Becerra said in a statement. “Today, we send a clear message: cheating the people of California will cost you more than it’s worth.”

BP’s overcharges amounted to at least $150 million to $300 million, according to the lawsuit. The state, which joined the case in 2014, sought triple damages plus civil penalties under the California False Claims Act. California alleged that BP systematically billed state and local government facilities at prices that exceeded what the company was allowed to charge under its contracts over almost a decade.

BP maintains the claims were “entirely without merit,” saying in an emailed statement that it “honestly and fairly” fulfilled its obligations to California.

“BP has agreed to this compromise settlement for an amount well below what the state demanded in its complaint,” according to the statement.

Brian Youngberg, energy analyst at Edward Jones & Co. in St. Louis, said the settlement “is a relatively small amount.” But anytime a company can settle litigation with “any government, it removes an uncertainty,” he said.

The lead attorney for the whistle blower said most of the $102 million settlement will go to state coffers, while his client will receive an unspecified share of it as a reward.

“Whistle blowers like Chris Schroen are vital to protecting taxpayers,” Niall P. McCarthy, of Cotchett, Pitre & McCarthy, said in a statement issued by the law firm. “Not only is BP paying over $100 million through this settlement, but with the conduct now stopped, taxpayers are saving millions of dollars more every year.”

BP acknowledged the risk it faced heading toward a trial that was expected to last four weeks.

California aimed to “whip up bias against a big, out-of-town oil company that seeks to operate profitably,” the company said in a December court filing. “They invite the jurors to punish the company for what it is and for earning a profit.”

The case is State of California v. BP America Production Co., CGC-12-522063, California Superior Court, San Francisco County (San Francisco).