RICHMOND — The House of Delegates on Tuesday passed a sweeping overhaul of the way Virginia regulates its electricity utilities, with one last-minute change aimed at fixing what some say is a significant flaw of the legislation.

An amendment offered by Del. David Toscano (D-Charlottesville) would prohibit utility companies from charging ratepayers twice for expensive projects to upgrade the grid and for investments in renewable energy.

The change is intended to prevent what some called a “double-dip” component of the original legislation, which lets utilities invest excess profit in new projects instead of returning money to ratepayers. According to critics, the original bill would let utilities keep the excess profit and build the cost of new projects into base rates.

Dominion Energy, the state’s biggest utility, helped write the original legislation and denied that it would have permitted double-dipping. The Toscano amendment passed despite opposition from Dominion — a measure of changing attitudes in the General Assembly toward the state’s most generous corporate campaign donor.

A slate of new Democrats erased a wide Republican majority in the House of Delegates in November, partly on promises to shake up the legislature’s cozy relationship with Dominion.

On Monday, the Toscano amendment initially passed on a 55-to-41 vote, with two abstentions. Then Republicans who control the chamber — sensing the political value of the vote — brought back the amendment, and it passed 96-to-1, with two abstentions.

The amended bill passed the full House on Tuesday by a vote of 63-to-35 with two abstentions.

Although some environmental and consumer groups, such as the Virginia League of Conservation Voters and the Natural Resources Defense Council, back the legislation because it makes renewable energy a priority, others say the bill remains problematic.

They say it fails to return enough money to ratepayers, takes away state oversight and gives Dominion a blank check for a host of projects — for instance, designating a pool of money for burying power lines around the state.

“The bill that passed today contains a $50 billion giveaway to Dominion to bury power lines using our money without government oversight,” said Tom Cormons of Appalachian Voices. “We commend the delegates who have sided with ratepayers as they work to improve this deeply flawed legislation. Barring significant changes, we hope they will continue to stand firm in opposition as the process moves forward.”

Despite having amended the bill Monday, Toscano voted against it on Tuesday.

“The amendment passed yesterday made the bill much better, but substantial problems remain to be fixed,” Toscano said via email. He added that he remains concerned that the bill removes layers of state oversight and slows the ability of consumers to get rebates for overpayment. “I am hopeful that these problems will be fixed during the next step of this process,” he said.

When the state Senate passed its version last week, it rejected an amendment to ban double dipping, so the two sides will have to reconcile their differences before the session wraps up in mid-March. Gov. Ralph Northam (D) helped broker the legislation and had endorsed the version that passed the Senate.

On Tuesday, Northam released a statement saying he is “pleased that the General Assembly continues to work constructively on this important issue.” He seemed to suggest the bill could be improved, saying that “if we can do better by consumers, we should, and I look forward to continuing to work with the General Assembly on getting this right.”

In 2015, the state agreed to freeze Dominion’s rates after the utility argued that it would face uncertain new costs under the Obama administration’s Clean Power Plan. But the Trump administration killed the plan, the costs never materialized and Dominion is estimated to have reaped hundreds of millions in excess profit during the rate freeze.

Sen. Chap Petersen (D-Fairfax City) has been a leading critic of the rate freeze and said he was surprised the House agreed to the Toscano amendment, but he said it does not address a fundamental problem: The bill continues to prevent the State Corporation Commission from overseeing rates and lets the utility spend its excess on new projects.

“I congratulate the House for winning the battle, but if you take away the SCC’s jurisdiction, you’re losing the war,” he said.

Former state attorney general Ken Cuccinelli (R) wrote to members of the General Assembly on Tuesday urging them to oppose the legislation, saying they were being played by Dominion.

He cited a recent analyst letter from UBS investment bank that was upbeat on Dominion stock because of the expected action from the Virginia legislature. The UBS note praised Dominion as being “adept at navigating VA politics” and added 5 percent to the expected value of its business in expectation of the General Assembly’s passing a favorable regulatory overhaul.

What Wall Street is saying, Cuccinelli told the lawmakers, is that Virginia is easy. “To use a dating analogy,” Cuccinelli wrote, “if Virginia were dating utilities, her name and phone number would be on the boardroom wall of every utility in the Commonwealth under phrases like ‘For a good time, call …’ ”

Sen. Frank Wagner (R-Virginia Beach), who sponsored the Senate version along with Sen. Richard L. Saslaw (D-Fairfax), shrugged off the House’s amendment. More significant, he said, is that the House’s overall approval of the bill is an endorsement of its basic concept — that the state should create a $200 million yearly funding stream so that Dominion can invest in an improved grid and more renewable energy.

“The House has endorsed everything in the bill. The Senate has endorsed everything in the bill. . . . We’re arguing now about how to pay for it,” Wagner said.

House Majority Leader C. Todd Gilbert (R-Shenandoah) initially opposed the Toscano amendment about double dipping but switched and voted in favor of it when the matter came up a second time. “I think it’s a legitimate enough concern that we should make sure it’s fixed,” he said.

Dominion was cautious about the amended bill. “First, we are pleased to see the bill has passed the House of Delegates,” spokesman David Botkins said. “We are still studying the effects of the Toscano amendment.”