The state of Massachusetts sued Exxon Mobil Corp on Thursday, accusing the oil giant of misleading investors and consumers for decades about the role fossil fuels play in climate change.

Attorney General Maura Healey filed the lawsuit shortly after Exxon lost a bid to delay the filing until after it is done defending itself in a trial that began Tuesday over similar allegations brought by the state of New York.

The lawsuit in Suffolk County Superior Court in Boston alleged Exxon systematically misled investors about climate-driven risks to its business and deceived auto drivers and other consumers about the role fossil fuel products play in causing climate change.

“Our goal here is simple: to stop Exxon from engaging in this deception and penalize it for this conduct,” Healey told reporters.

Her lawsuit, the culmination of a three-year investigation, was filed two hours after a judge rejected a last-minute bid by Exxon to force Healey to hold-off from moving forward with her plans to sue it.

In court papers, Exxon called the decision by Healey to sue now “gamesmanship” to distract its lawyers amid the New York trial and part of a “partisan” campaign against it.

“We look forward to refuting the meritless allegations in court,” Exxon said in a statement.

Healey, a Democrat, and her New York counterpart launched investigations into Exxon following news reports in 2015 saying company scientists determined that fossil fuel combustion must be reduced to mitigate the impact of climate change.

Those news reports, by InsideClimate News and the Los Angeles Times, were based on documents from the 1970s and 1980s. Exxon said the documents were not inconsistent with its public positions.

Healey in 2016 issued a so-called civil investigative demand to Exxon seeking documents to determine whether it had violated Massachusetts consumer-protection law through its marketing and sale of fossil fuel products.

The company fought the records request, and while courts have sided with Healey, the company to this day has not provided her office any records. The state built its lawsuit on evidence from other sources, including New York’s case, Healey said.

In its 2018 lawsuit, New York accuses Exxon of falsely telling investors it had properly evaluated the impact of future climate regulations on its business, defrauding investors out of up to $1.6 billion.

Exxon denies wrongdoing and says it has a robust system to manage the risk of increasing climate change.