ExxonMobil prevailed Tuesday in its much-watched legal battle with the state of New York, beating back claims that it misled investors for years in how it calculated the financial risks of climate change.

The high-profile trial, which included testimony from former ExxonMobil chief executive and former secretary of state Rex Tillerson, marked the culmination of a four-year-old probe under three different New York attorneys general, during which Exxon handed over millions of documents about its internal dealings.

But that extensive effort wasn’t enough to convince New York Supreme Court Judge Barry Ostrager that the oil and natural gas giant broke state securities laws when describing to shareholders how it analyzed the effect of future greenhouse gas regulations on the company’s bottom line.

During a 12-day trial this fall, the state tried to wield a powerful anti-fraud law, called the Martin Act, that does not require prosecutors to prove that a company intended to deceive investors. The office of Letitia James, New York’s current attorney general, tried to show the company lied to investors by keeping two sets of books — one public, one private — for estimating the cost of complying with future climate regulations.

But even with that relatively low bar, Ostrager found New York’s allegations “to be without merit” and the use of the state’s securities law to be a stretch in this case. Ostrager found that Exxon had been transparent about the two different ways it calculated those costs.

“Nothing in this opinion is intended to absolve ExxonMobil from responsibility for contributing to climate change,” Ostrager wrote in his ruling. “ExxonMobil does not dispute either that its operations produce greenhouse gases or that greenhouse gases contribute to climate change. But ExxonMobil is in the business of producing energy, and this is a securities fraud case, not a climate change case.”

In the harshly-worded ruling, Ostrager said that the New York attorney general had not produced any investor who was harmed and that it failed to show “that ExxonMobil made any material misstatements or omissions about its practices and procedures that misled any reasonable investor.”

Ostrager went on to call New York’s complaint “hyperbolic” and “ill-conceived” and said he did not find the testimony of any Exxon employee “to be anything other than truthful."

During the trial, Ostrager appeared at times impatient with New York’s lawyers. On the last day of proceedings, the state dropped two of its four claims against Exxon in a bid to narrow its argument and secure victory.

Exxon saw the decision as vindication that it had been besieged by a politically motivated attack in a state controlled by Democrats.

“Today’s ruling affirms the position ExxonMobil has held throughout the New York Attorney General’s baseless investigation,” Exxon spokesman Casey Norton said. “We provided our investors with accurate information on the risks of climate change. The court agreed that the Attorney General failed to make a case.”

“Lawsuits that waste millions of dollars of taxpayer money do nothing to advance meaningful actions that reduce the risks of climate change,” he added.

In a statement, the office of Letitia James, New York’s current attorney general, insisted that the case had been worth pursuing. She said that “for the first time in history, ExxonMobil was compelled to answer publicly for [its] internal decisions that misled investors.” She said that “Exxon’s inability to tell the truth, further underscores the lies that have been sold to the American public for decades.”

The New York case is hardly the only litigation Exxon faces when it comes to climate change. With Congress too gridlocked to pass major climate legislation, many left-leaning states and cities have turned to the courts to hold oil companies accountable for their contributions to the changing climate.

“Round one goes to Exxon, but this is going to be a longer fight,” said Andrew Logan, director of the oil and gas program at Ceres, a non-profit group of environmentalists and investors.

In October, Massachusetts Attorney General Maura Healey sued Exxon for “deceptive advertising to Massachusetts consumers and for misleading Massachusetts investors about the risks to Exxon’s business posed by fossil fuel-driven climate change—including systemic financial risk.”

Chloe Gotsis, a spokeswoman for Healey’s office, said Massachusetts is not daunted by the ruling from New York since its claims relate to advertising, and not just cost estimates for complying with regulation.

“We will continue our work to hold the company accountable for its misrepresentations,” she said.

Logan said the emphasis on consumers and misinforming the general public in the Massachusetts case would avoid the need to find harm to a “reasonable investor."

“These cases will get easier to prove unfortunately as climate change gets worse,” he said. “But if you wait long enough for damage to be obvious, you miss the opportunity to prevent it in the first place.”

In addition, a slew of other local governments -- including those of Baltimore, Rhode Island, San Francisco and Oakland, as well coalitions of communities in the mountains of Colorado and along the coast of California -- are seeking compensation from oil companies for the damage rising temperatures have already wrought to drought-plagued farmers and beachfront businesses.

Those local governments claim Exxon and other oil companies have created a “public nuisance” -- a charge more typically brought against a noisy neighbor -- for the heat-trapping pollution their products have put into the atmosphere.

So far, federal district courts have been sorting out whether the claims should be heard at the state or federal level. Oil firms have sought to move the cases to the federal court system since the Supreme Court has ruled in favor of the petroleum industry in a 2011 public nuisance suit.