NEW YORK — A federal judge on Thursday dismissed a lawsuit by Exxon Mobil aimed at stopping an investigation by New York and Massachusetts officials into whether the oil giant misled investors and the public about its knowledge of climate change and how the issue could affect its business.

“Exxon’s allegations that the AGs are pursuing bad faith investigations in order to violate Exxon’s constitutional rights are implausible and therefore must be dismissed for failure to state a claim,” Manhattan U.S. District Judge Valerie Caproni said.

In her ruling, Caproni described Exxon’s lawsuit as “running roughshod over the adage that the best defense is a good offense.”

Exxon sued New York Attorney General Eric Schneiderman and his Massachusetts counterpart, Maura Healey, in 2016 after they subpoenaed documents about Exxon research into the role of fossil fuels in climate change.

The global oil and gas company called their investigation politically motivated and accused the Democrats of trying to take away the company’s free-speech rights on an important issue.

Schneiderman late Thursday said he was pleased with the court’s decision.

“As the Court noted, Exxon’s claims in this lawsuit were ‘implausible’ and unsupported, while its strategy amounted to a type of ‘legal jiu-jitsu’ that resulted in nothing more than a ‘huge waste’ of time and money,” Schneiderman said.

Healey called it a “turning point” in their investigation and a “victory for the people.”

The Irving, Texas-based Exxon said it was reviewing the judge’s decision and evaluating its next steps.

“We believe the risk of climate change is real and we want to be part of the solution,” Exxon said in a statement. “We’ve invested about $8 billion on energy efficiency and low-emission technologies such as carbon capture and next generation biofuels.”