The push to drain Yosemite’s Hetch Hetchy Reservoir and restore the Sierra canyon to its natural state was rejected by the courts — again — Monday, though opponents of the dam said they plan to take their fight to the California Supreme Court.

In a legal case that has been a thorn in the side of the city of San Francisco, California’s Fifth District Court of Appeal in Fresno ruled that a Tuolumne County judge was correct two years ago when he tossed a lawsuit seeking to raze the city-run reservoir.

Restore Hetch Hetchy, a Berkeley group, has argued that San Francisco should not have rooted its water supply in a national park because it overran a pristine valley and violated a provision of the state Constitution requiring reasonable water use. But the appeals court agreed with the lower court that the city had federal permission to build the reservoir and didn’t need to meet the state standard.

“Congress specifically ordered the creation and operation of a dam, intending for the continued operation of this structure,” wrote the three-judge appeals panel. “The trial court correctly concluded Restore Hetch Hetchy’s claims are preempted under federal law.”

The reservoir on the Tuolumne River has long faced opposition, even before it got off the ground in the early 1900s.

Renowned naturalist John Muir made the fight against the dam one of his defining causes, equating the canyon’s beauty to the more popular Yosemite Valley and insisting that granite domes and towering waterfalls not be compromised for a municipal water supply.

However, San Francisco officials were desperate for more water at the turn of the century, especially when the 1906 earthquake and subsequent fires exposed the shortfalls of its reserves.

In 1913, President Woodrow Wilson signed the Raker Act, authorizing construction of the O’Shaughnessy Dam, which created the Hetch Hetchy Reservoir.

San Francisco officials have maintained that the legality of Hetch Hetchy has long been settled and that the water supply has become indispensable for the region.

Today, the reservoir anchors a sprawling waterworks that serves 2.7 million residents and businesses in more than a dozen Bay Area communities. It also generates hydroelectric power.

Restore Hetch Hetchy initiated the fight against the complex six years ago when it qualified an initiative for the San Francisco ballot that would have required the city to explore removing the dam. The measure was defeated. In 2015, the group filed a lawsuit.

On Monday, Spreck Rosekrans, executive director of Restore Hetch Hetchy, insisted that despite the latest setback, the reservoir remains in violation of state law.

“We are convinced that the legal and technical merits of our case are well-founded and we plan to ask the California Supreme Court to review this ruling,” he wrote in an email to the Chronicle. “We are hopeful that the highest court in the state will understand the important states’ rights issues that this case brings forward.”

Kurtis Alexander is a San Francisco Chronicle staff writer. Email: kalexander@sfchronicle.com Twitter: @kurtisalexander