RICHMOND, Va. — Gov. Ralph Northam has approved legislation that could lead to substantial new additions to most Virginians’ electric bills while making it easier for utilities to build renewable energy projects and improve the electric grid.

Northam signed into law Friday legislation that was shepherded through the General Assembly by Dominion Energy, the state’s biggest electric monopoly. Dominion has long been the state’s most politically influential company but has increasingly become a punching bag of populist politicians in both parties.

The Democratic governor signed the bill despite warnings from Attorney General Mark Herring that it will allow utilities to continue charging higher-than-necessary prices.

Northam said the final product is much better than what Dominion initially proposed. His office oversaw hasty negotiations earlier this year between utilities, environmental groups, consumer advocates and others that led to changes in some parts of the legislation, but kept much of the original product.

“There probably are some folks out there that say it could be done better, but I would say I think we did a good job,” Northam told reporters last week.

The sweeping overhaul of electric regulations undoes a 2015 law that temporarily prevented state regulators from lowering Dominion and Appalachian Power’s rates, which led to windfalls for both utilities. Appalachian Power is the state’s second largest utility and serves the western third of the state.

Both companies will have to refund customers some of their overearnings that resulting from the 2015 law. They will also have to pass on savings resulting from recent federal tax cuts. For the average Dominion residential customers that will mean a short-term monthly decrease of about $6 a month.

The new law also mandates new spending on energy efficiency programs, which could lower customers’ overall energy usage and bills.

On the new costs side: the new law allows Dominion to bury about 4,000 miles of power lines, which regulators estimate will eventually add $5 a month to an average residential customer’s bill. Experts have said the $2 billion project will translate to only a 0.00002 percent increase in reliability, while Dominion says the project has significant value for the state.

Utilities will also be able to write off certain costs related to the early retirement of power plants and other areas faster than they can now. That provision largely eliminates the chances that regulators will find that rates are too high and need to be lowered.

Dominion “will now benefit from stable rates for essentially 7 years,” Bank of America-Merrill Lynch said in a recent analysis.

What that may cost customers is unclear, but regulators inability to lower rates in 2015 and 2016 led to the average residential customer paying $3 extra a month. Possible new rate add-ons to pay for grid modernization and renewable energy project costs could add several dollars more each month.

As in 2015, Dominion lined up wide support for this year’s effort. That includes key lawmakers, environmental organizations, and trade groups, many of whom signed on in support because of specifically tailored provisions in the legislation.

But many of the same opponents of the 2015 law, including Herring, have been steadfast in opposition this year. They’ve argued that new restrictions on how regulators account for costs aren’t necessary to increase renewable energy production and improve the grid.

The legislation’s passage is proof of Dominion’s continued influence in Virginia politics, but there were signs that its strength may be waning.

New lawmakers were far more likely to vote against the bill than veteran ones. And Dominion lost a key House floor vote on an amendment that regulators say would have allowed the company to charge double for some capital projects, a public rebuke that longtime political watchers said was unprecedented.