California may soon become the first state in the nation to require that virtually every new home be equipped with solar panels.

The California Energy Commission on Wednesday is expected to mandate solar arrays on almost all new single-family houses built after Jan. 1, 2020, as part of the state’s fight against global warming. The rule also would apply to new multifamily buildings up to three stories tall.

The proposal, years in the making, would provide an immense boost to the state’s solar industry, which lost jobs in 2017 after years of rapid growth. It would also move California closer to a long-held goal of creating “zero net-energy” buildings, which generate as much electricity as they use over the course of a year.

But the solar requirement would come at a cost.

Together with tough new efficiency standards for windows and insulation that the commission will consider Wednesday, the solar mandate could add $10,538 to the cost of building a house, by the agency’s own estimate. The extra expense would hit at a time when California is suffering a severe and deepening housing affordability crisis.

The move’s supporters insist the solar homes would save their owners money by slashing monthly utility bills. That savings could be worth $16,251 over the 30-year life of the house, according to the commission.

“We do not minimize the cost of housing in the state — everyone recognizes that’s an issue,” said Andrew McAllister, one of the Energy Commission’s five voting members. “Their cash-flow position will be improved with the addition of solar. It won’t make it worse.”

Although housing developers had concerns about the move, Bob Raymer with the California Building Industry Association said the commission had given the new rule enough flexibility to make it work — for example, if the roof is too small or shaded, the builder can compensate by using energy-efficiency measures inside the house. And he agreed that the energy savings for the new solar homes would offset the up-front costs.

“We’re going to be able to look the home buyer in the eye and say, ‘You are going to get your money back,’” said Raymer, the group’s technical director.

California first started imposing new energy-efficiency standards for homes in the 1970s, slowly ratcheting them up over time. As a result, per-capita electricity demand in the state largely stayed flat, even as it grew elsewhere in the country.

The fight against global warming gave those standards new urgency. In 2007, both the Energy Commission and the California Public Utilities Commission set a nonbinding goal of having all new residential construction by 2020 be zero net-energy.

That same year, the state initiated solar financial incentive programs both for new homes and owners of existing houses. But the state’s solar market was still in its early stages, and it wasn’t clear whether or how California could meet its zero net-energy goal.

“If you think about the context of 10 or 12 years ago, things were a lot different,” McAllister said. “Solar was not an everyday thing. Well, now it is.”

About 20 percent of new homes in California are built with rooftop solar arrays, Raymer said. And prices have tumbled as the solar industry, both in California and around the world, matured.

The national average installed cost of a new residential array has fallen by more than half since 2007, according to the annual “Tracking the Sun” survey from Lawrence Berkeley National Laboratory. In California, the median price hit $4.3 per watt in 2016, the most recent year for which data are available. For a 3-kilowatt system, that adds up to $12,900.

California’s solar industry endured a rough 2017, as a longer-than-usual rainy season and state regulatory changes drove down both new solar installations and employment for the first time in years. About 86,400 Californians worked in solar power last year, down 13 percent from 2016.

Then in January, President Trump dealt the industry another setback when he imposed temporary tariffs on imported solar panels, which will push up the installed price of new solar arrays unless installers find ways to trim their own operational costs.

McAllister said the commission revised its calculations following the tariff announcement and concluded that the new rule would still make financial sense.

“It’s very clear that solar will be cost-effective,” he said.

To environmentalists, the move is an important step to curbing greenhouse gas emissions. When the electricity they use is factored in, buildings represent the second-largest source of greenhouse gases in the state, behind only transportation. California law calls for cutting the state’s total carbon emissions 40 percent below 1990 levels by 2030.

“This is a key measure to reduce (greenhouse gases) in the building sector, which is one area in California where there hasn’t been enough attention,” said Rachel Golden, a senior campaign representative for the Sierra Club. “We have strong policies to clean up the utility sector, strong policies on transportation, but we don’t have strong policies on the decarbonization of buildings.”

David R. Baker and Kurtis Alexander are San Francisco Chronicle staff writers. Email: dbaker@sfchronicle.com, kalexander@sfchronicle.com Twitter: @DavidBakerSF @kurtisalexander