National Grid on Monday said it’s reached a deal with state officials to end a moratorium on new natural gas service in New York City and begin hooking up connections that have been delayed for months.

Gov. Andrew Cuomo’s administration, which has been sparring with the utility over the moratorium it enacted earlier this year in the face of a gas supply shortage, also announced that the company would pay more than $30 million in penalties that would also support energy conservation and clean energy projects.

National Grid has identified short-term supply options to meet anticipated demand in the region for the next two years. Under the agreement, the company said it would enhance demand response, strengthen energy efficiency programs and increase reliance on portable compressed natural gas.

The utility has agreed to present options to meet New York’s long-term supply needs within three months. It plans to present those findings and take feedback during public meetings in Brooklyn, Queens, Nassau and Suffolk counties.

Ultimately, National Grid said it’s aiming to finalize a long-term plan that would address supply constraints by June 2020 “to allow a safe, adequate construction and transition period and have the long-term option or options in place and functioning in approximately two years.”

In all, the utility said it would offer $7 million in customer assistance to address any hardships that were caused by the moratorium, along with another $8 million for new energy efficiency and gas conservation measures. The company also plans to invest $20 million in clean energy projects and businesses in New York.

“Every decision we make is driven by National Grid’s commitment to provide safe and reliable service to our customers, including the decision to implement the moratorium,” said Badar Khan, interim president of National Grid U.S. “We understand the frustrations of everyone who experienced a delay in service during this period and regret that we did not provide more notice or explanation to our customers about the moratorium.”

The agreement resolves an investigation that the New York State Public Service Commission (PSC) had opened on National Grid and the moratorium. An independent monitor will oversee the utility’s compliance with the agreement.

Monday’s announcement came after a strongly worded letter from Cuomo about two weeks ago in which the governor warned that the state would move to revoke National Grid’s operating certificate unless it outlined a plan to end the moratorium and address supply issues within 14 days.

“This agreement is a victory for customers,” Cuomo said. “National Grid will pay a significant penalty for its failure to address the supply issue, its abuse of its customers and the adverse economic impact they have caused…Today it was made clear that we will not allow any business — big or small — to extort New Yorkers in order to advance its own interests.”

The company stopped processing applications for new gas service in Brooklyn, Queens and Long Island earlier this year. The company said it couldn’t serve commercial, residential and multi-family units without additional infrastructure to bring more supply into New York City. The moved stopped 2,600 applications and impacted an estimated 20,000 people, National Grid said. It has been working to connect service for some of those customers after the PSC ordered it to do so last month.

Cuomo accused the utility of failing to plan for supply needs and depending too heavily on Transcontinental Gas Pipe Line Co. LLC’s Northeast Supply Enhancement (NESE) project, which is fully subscribed by National Grid subsidiaries. However, both New York and New Jersey have rejected key permits for the pipeline, preventing it from advancing.