The First District Court of Appeals in San Francisco late Thursday afternoon ruled it would defer to the California Public Utilities Commission (CPUC), whose members voted 4-1 in May 2015 to approve a contract for the power plant.

In a 14-page ruling, the appeals court said the CPUC was “just and reasonable” and its decision on the contract was supported by the evidence.

A number of environmental groups filed suit to try to stop the construction of the natural gas-fired Carlsbad Energy Center.

“It’s both a tragedy and a travesty,” said April Rose Sommer, executive director of the Protect Our Communities Foundation, which took part in a petition to the appeals court asking for a review of the CPUC’s decision. “It’s totally in opposition to the state’s efforts to reduce greenhouse gases and transition away from a fossil fuel-based energy system.”

“We appreciate that the Court of Appeal has upheld the CPUC’s decision to approve the contract for the Carlsbad Energy Center, which recognized that the Carlsbad Energy Center is the best approach,” NRG spokesman David Knox said in a statement.

San Diego Gas & Electric plans to buy power from the plant.

“The energy produced from the Carlsbad Energy Center is expected to complement the growing amount of renewable energy, private solar, energy storage, electric vehicles and other clean energy innovations being added every day to the modern grid powering our lives,” said SDG&E spokeswoman Allison Torres in a statement.

Critics say the plant will harm the environment along the coastline, especially the nearby Agua Hedionda Lagoon and question whether the power plant is needed at all.

“Due in large part to the growth in rooftop solar, the latest demand projections for the San Diego region are far less than expected,” said Sierra Club attorney Will Rostov in an email. “This suggests that the plant isn’t needed. The California Public Utilities Commission’s troubling history of approving costly unneeded gas plants needs to stop.”

The 62-year-old Encina Power Station is being retired in large part due to its cooling systems that suck in seawater, a process called “once-through cooling” that regulators have opposed in recent years because it harms marine life.

Part of the rationale for the construction of the Carlsbad Energy Center was to make up for the loss of electricity generation from the now-shuttered San Onofre Nuclear Generating Station.