After four years of legal sparring and finger-pointing, oil-industry giant Exxon Mobil went to court on Tuesday to face charges that the company lied to shareholders and to the public about the costs and consequences of climate change.

The case turns on the claim that Exxon kept a secret set of financial books that seriously underestimated the costs of potential climate change regulation while claiming publicly that it was taking such factors into account. It follows a sprawling investigation that included millions of pages of documents and allegations of a chief executive’s secret email account.

In his opening statement, Kevin Wallace, a lawyer with the New York Attorney General’s office, argued that “the gap between what Exxon said it was doing and was actually doing was significant, and had an impact on the bottom line.”

While “we are not telling Exxon how to run its business,” Mr. Wallace said in closing, the company, he said, “has to be honest with investors.”