The steel mill in Yazd pours its heats between 11 p.m. and 7 a.m. now, when the grid has power to spare. Its 2,300 workers have swapped their lives around to match, and the city’s bakeries have begun opening at 3 a.m. to serve them.

Iran is entering its third year of structural electricity shortages that have spread from the summer peak into autumn and, for the first time, threaten to persist through the winter. The state grid operator reported a gap between generation capacity and demand of about 20,000 megawatts at this summer’s peak, roughly a quarter of total demand, and has told heavy industry to expect limits on supply of between 50 and 90 percent of normal through at least November. Residential customers in Tehran and most provincial capitals face scheduled two-hour outages that are published daily by district.

The paradox has not escaped Iranians. The country holds the second-largest natural gas reserves in the world and sits on vast oil deposits, yet it cannot keep the lights on. The causes are several: decades of subsidized prices that make electricity nearly free and discourage efficiency, a power plant fleet that has lost capacity to deferred maintenance under sanctions, gas output from the South Pars field that has plateaued as pressure declines, and a drought that cut hydroelectric generation by about 40 percent this year. Cryptocurrency mining, both licensed and illicit, is estimated by the grid operator to draw as much as 2,000 megawatts.

“Every year we are told it is the heat, or the water, or the miners,” said Farideh Sadeghi, who runs a textile workshop with 40 employees in the city of Qom. “It is all of those and it is none of them. It is that nobody built a power plant.”

The economic effect is now measurable. The steel industry, which accounts for about a tenth of the country’s non-oil exports, reported output down 14 percent in the first half of the Iranian year, and the cement association has said 30 plants have shut kilns. Economists at a Tehran research institute estimated the cost of power cuts to industrial output at about 2 percent of gross domestic product this year. The government has begun allowing large plants to build their own gas-fired generation, and about 3,000 megawatts of such capacity is under construction, though the gas to run it is itself constrained in winter when households take priority for heating.

The energy ministry has announced a program to add 7,000 megawatts of solar capacity within two years, and solar farms are rising on the desert outskirts of Yazd, Kerman and Isfahan. Officials have also raised electricity tariffs for the highest-consuming households for the first time in a decade, a politically delicate step in a country where energy subsidies have long been a form of social contract.

“Solar is the right answer, but 7,000 megawatts in two years is a slogan, not a schedule,” said Hossein Mahdavi, an energy economist formerly with the ministry who now consults for private developers. “The realistic figure is half that, and demand grows by 3,000 a year.”

In Yazd, the night shift has acquired a culture of its own. Ali Reza Kazemi, 38, who supervises a rolling line, said his children had learned to sleep through the sound of his departure at 10 p.m. “My father worked days and complained about the heat,” he said. “I work nights and complain about the dark. This is progress, in Iran.”