Shielded in this way, the utilities would be more likely to maintain the investment-grade credit ratings needed to borrow at affordable interest rates. “They face a downgrade to junk-bond status if they do not do this,” said Michael Wara, a research fellow at the Steyer-Taylor Center for Energy Policy and Finance at Stanford University.

The utilities have 15 days after the bill is signed to choose whether to take part in the fund as contributors. The establishment of the larger fund requires the participation of both Southern California Edison and San Diego Gas & Electric. PG&E’s eligibility is contingent on its emergence from bankruptcy and settling of existing claims.

Whether or not the utilities contribute, the fund created by the legislation cannot be tapped for expenses from past wildfires.

The big question is whether a $21 billion fund will be enough to cover the damages that the utilities may have to pay in the coming years. A single catastrophic fire could drain much of the fund. PG&E, for instance, said in a financial filing this year that its liability related to the Camp Fire could come to $10.5 billion.

“The insurance pool is only so big, so if we have a fire season like we’ve had in the past two years, it won’t be enough,” Mr. Wara said. The hope is that large fires become less frequent as the utilities invest large sums to make their service areas safer. “It is now incumbent on the utilities to get their house in order,” he said.

The measure requires the utilities to spend $5 billion on safety improvements. And lawmakers tied future executive compensation at the utilities to the companies’ safety performance.