SAN JUAN, Puerto Rico — An explosion and fire at an electric substation threw much of northern Puerto Rico into darkness late Sunday in a setback for the U.S. territory's efforts to fully restore power more than five months after Hurricane Maria started the longest blackout in U.S. history.



The island's Electric Power Authority said several municipalities were without power, including parts of the capital, San Juan, but they were optimistic it could be restored within a day as they worked to repair a substation that controls voltage.



The blast illustrated the challenges of restoring a power grid that was already crumbling before it was devastated by the Category 4 hurricane.



In many cases, power workers are repairing equipment that should have long been replaced but remained online due to the power authority's yearslong financial crisis. PREPA is worth roughly $4 billion, carries $9 billion in debt and has long been criticized for political patronage and inefficiency. It also struggled with frequent blackouts, including an island-wide outage in September 2016.



It was not immediately known what caused Sunday's fire, which was quickly extinguished. Officials said the explosion knocked two other substations offline and caused a total loss of 400 megawatts worth of generation.



"We are trying to restore that as quickly as possible," the company said.



Heavy black smoke billowed from the substation as neighbors in the area described on social media seeing the sky turn orange following a loud explosion. San Juan Mayor Carmen Cruz tweeted that no injuries had been reported and that power had been restored in some areas of the city.



The blackout comes as more than 400,000 power customers remain in the dark more than five months after Hurricane Maria. The storm destroyed two-thirds of the island's power distribution system and caused up to an estimated $94 billion in damage.



Puerto Rico's governor announced last month that he plans to privatize the state-owned power company, which relies on infrastructure nearly three times older than the industry average. It would be the largest restructuring of a public entity in U.S. history.



One week after his announcement, a federal control board overseeing the island's finances asked that a judge authorize a loan of up to $1.3 billion so the power company can keep operating. The board said the company could see an estimated $1.2 billion loss in revenue in the first six months after Hurricane Maria.