On Tuesday, residents scrambled to buy generators and many stores were already out. Cars lined up outside gas stations and many stations were already rationing the amount of gas they were selling per customer. Residents flocked to supermarkets and waited in line for hours, expecting to be without power for weeks, maybe even months.

Roberto Rivera, 61, raced to buy canned foods and two 24-packs of water bottles.

“I came immediately because I couldn’t buy anything for Irma,” Mr. Rivera said inside a packed supermarket in San Juan. “I see everyone is on the same boat here.”

Mr. Rivera is a construction worker for the government-owned Puerto Rico Electric Power Authority, known as Prepa. Even he expects that the power grid will collapse.

“It’s going to come down again,” he said. “No doubt.”

Burdened by the island’s debt crisis, the utility effectively declared bankruptcy in July and cannot tap into capital markets after defaulting on $9 billion in bond debt.

Over the years, the agency has been unable to make the appropriate upgrades and improvements to its system.

Efforts to modernize Prepa’s plants, which burn imported oil to produce electricity, and diversify energy sources have mostly come to a halt. So has much routine maintenance like trimming trees near power lines.