LOS ANGELES — Big Oil lost a pair of court battles Tuesday that could lead to trials in lawsuits by California cities and counties seeking damages for the impact of climate change.

The 9th U.S. Circuit Court of Appeals rejected arguments by energy companies and ruled state courts are the proper forum for lawsuits alleging producers promoted petroleum as environmentally responsible when they knew it was contributing to drought, wildfires, and sea level rise associated with global warming.

The lawsuits claim Chevron, Exxon Mobil, ConocoPhillips, BP, Royal Dutch Shell and other companies created a public nuisance and should pay for damage from climate change and help build sea walls and other infrastructure to protect against future impact — construction that could cost tens of billions of dollars.

The ruling overturned a decision by one federal judge, who had tossed out lawsuits brought by the cities of San Francisco and Oakland.

“It is time for these companies to pay their fair share,” San Francisco City Attorney Dennis Herrera said in a statement applauding the ruling. “They should not be able to stick taxpayers with the bill for the damage they knew they were causing. We will continue to hold these companies accountable for their decades-long campaign of public deception about climate change and its consequences.”