Working under a legal principle known as the public trust doctrine, which can be used to compel the government to preserve natural resources for public use, the initial complaint stated that government officials had “willfully ignored” the dangers of burning fossil fuels.

The five years since the case was first filed have been the five hottest years in the age of accurate records.

The 21 young plaintiffs, now between the ages of 12 and 23, claim that the government’s actions, and inaction, in the face of global warming violate their “fundamental constitutional rights to freedom from deprivation of life, liberty, and property.” Their personal stories include damage from rising sea levels and wildfire smoke, but they argued that they will be dealing with even more disastrous effects of climate change within their lifetimes.

The youngest of the plaintiffs, Levi Draheim, will be just 33 in 2040, the year by which a United Nations scientific panel now expects some of the biggest crises to unfold.

During the hearing in June that led to the new opinion, Judge Hurwitz pressed Ms. Olson with a question that signaled his skepticism about the courts taking the leading role in combating as big a problem as climate change: “You’re asking us to do a lot of new stuff, aren’t you?”

Ann Carlson, an expert in climate change law at the University of California Los Angeles School of Law, said what surprised her and many other experts was how far the lawsuit had proceeded.

“I’ve always thought this case was creative and interesting but a long shot,” she said, “and after listening to the oral argument I thought that the court would find some way to dismiss the case that reflected its concerns about just how big the remedy was that the plaintiff were seeking in the case” — that is, she said, to “get the United States to stop emitting carbon into the atmosphere.”