NextEra Energy Inc., the world’s largest producer of wind and solar energy, swung to a loss in the fourth quarter, dented by an impairment charge of $1.2 billion on its investments in the Mountain Valley natural gas pipeline.

Mountain Valley pipeline, which stretches from West Virginia to Virginia, is one of the several oil and gas pipelines delayed in recent years by regulatory and legal fights with states and environmental groups that found problems with permits issued by the Trump administration.

Most recently, federal energy regulators did not approve a request to ramp up construction of a part of the pipeline, which is expected to transport 2 billion cubic feet per day of gas from the Marcellus/Utica shale formation in West Virginia, Pennsylvania and Ohio to Virginia.

The natgas pipeline, owned by units of Equitrans Midstream Corp. and NextEra, among others, is currently estimated to be in service by late 2021.

Analysts, however, expect the pipeline’s startup to be delayed after Virginia environmental regulators proposed changes to stream-crossing rules that would bar Mountain Valley from using the U.S. Army Corp’s proposed 2020 Nationwide Permits to cross streams.

NextEra on Jan. 26 attributed its writedown to legal and regulatory challenges, saying the project is facing “substantial delays in reaching commercial operation and increased costs associated with those delays.”

The company posted a net loss of $5 million in the three months ended Dec. 31, from an income of $975 million a year earlier.

Excluding the charge and other items, the company’s profit of 40 cents per share beat analyst estimates of 37 cents, helped by a surge in demand for renewable power generation.

The company’s shares were marginally up at $87.30 in premarket trading.