AS MASSACHUSETTS SEEKS to transition away from fossil fuels and achieve net zero emissions by 2050, what to do with the state’s existing natural gas infrastructure is becoming a major point of contention.

At a hearing Tuesday of the Senate Committee on Global Warming and Climate Change, several senators pressed Energy and Environment Secretary Kathleen Theoharides on why the Baker administration’s recent building code proposal doesn’t allow communities to experiment with banning fossil fuel infrastructure for heating and cooking in new construction.

Theoharides said the proposal would update two existing building codes and create a new third one. None of the codes would ban fossil fuel infrastructure in new buildings but they would be structured in a way to make it cost effective for builders to embrace electrification.

“What we’ve done through the code is make the case for electrification really strong based on the cost,” she said.

The existing building codes — a base code and a stretch code — would be updated to put downward pressure on greenhouse gas emissions in new buildings. The new opt-in net zero specialized stretch code would require new homes or commercial buildings using gas to achieve greater energy efficiency and also mount solar on the roof and pre-wire the building for electrification.

Theoharides said the administration’s proposal seeks to strike a balance between energy efficiency and cost. She said she opposes an outright ban on fossil fuel infrastructure in new construction even in individual communities that want to do so because such bans could hinder housing construction and because they could leave a smaller pool of customers carrying the financial load for the remaining natural gas system.

“We need to make a transition [away from natural gas], but it needs to be an orderly transition,” she said. “We think we have to do this with a high level of care when we’re transitioning away from a system that still exists all across the state.”

Sen. Cynthia Creem of Newton disagreed. “I think it’s shortsighted,” she said. “You may save money now but in the long run it’s not going to help.”

Sen. Michael Barrett of Lexington said Theoharides was stifling innovation by not allowing communities to experiment with doing away with fossil fuel infrastructure.

Theoharides disagreed. “Dictating certain fuels be used or certain things be banned is not innovation, it’s a requirement. What we’re doing is creating a code that requires the most energy efficient building envelope possible as well as additional things that go beyond that,” she said. “What we are not requiring is that every individual building new in a community needs to offset its entire energy profile. We do not believe that every homeowner needs to be an energy farmer and produce or offset all of the energy that’s used. That job can be efficiently done at the state level by procuring clean energy for our electricity and by transitioning away from fossil fuels.”

Barrett said Theoharides is trying to avoid a rapid migration away from natural gas, but he said her building codes would steer developers in the same direction by making it more expensive to build with fossil fuel infrastructure.

“It would,” Theoharides said. “But we think the transition would be smoother.”

She said natural gas delivery companies need to be part of the transition to a future without their product. The energy secretary said she wants the companies to make the transition to a carbon-free future without leaving stranded assets behind.

The Department of Public Utilities has ordered the state’s natural gas utilities to release a report in March detailing their vision for the future of their business. In a letter to the DPU on Tuesday, the attorney general’s office and the Department of Energy Resources urged the agency to put forward reforms by the end of this year to prevent homeowners and businesses from getting hit with costs as demand for natural gas declines over time.

“Over the next few months, the DPU has the opportunity to conduct an inclusive and open process that will lay the groundwork for a transition away from natural gas that is fair, safe, reliable, and affordable for all customers,” Attorney General Maura Healey said in a statement. “We urge the DPU to take this opportunity to ensure we move toward our clean energy future in a way that is expeditious and protects ratepayers.S