From the roof of a 12-story apartment building in the Beirut district of Achrafieh, the view in every direction is the same: panels, tilted south, on nearly every flat surface, with water tanks and satellite dishes squeezed between them.

Lebanon has installed roughly 1,900 megawatts of solar capacity since 2020, according to an estimate published last week by the Lebanese Center for Energy Conservation, almost all of it on private rooftops and factory sheds and almost none of it planned by the state. The figure now exceeds the effective generating capacity of Électricité du Liban, the national utility, which supplies most of the country for between two and six hours a day. The center estimates that solar provided about 28 percent of the electricity consumed in Lebanon in the first half of this year.

The transformation was driven by collapse rather than policy. When the Lebanese pound lost more than 95 percent of its value beginning in 2019, the utility could no longer buy fuel, and households that had long paid a second bill to neighborhood diesel generator operators found that bill rising to $200 or $300 a month. Solar panels, imported mainly from China and paid for in cash dollars, became the cheaper option within two years. A 10-kilowatt system with batteries now costs about $6,000 in Beirut, down from $11,000 in 2022.

“No minister decided this. No bank financed it. People looked at the generator bill, looked at the sun, and did the arithmetic,” said Nadine Gebran, an engineer who runs an installation company with 60 employees, up from four in 2021. “We have become the most distributed power system in the Middle East by accident.”

The accident has consequences. The grid was never designed for power to flow back from rooftops, and the utility has no net-metering system that functions at scale, so most households store surplus power in lead-acid or lithium batteries or simply waste it. The diesel generator operators, an informal industry estimated to employ 25,000 people and to have generated about $1.5 billion a year at its peak, have seen demand fall by half; several have begun offering solar installation themselves. Battery disposal has become a visible problem, with an estimated 40,000 tons of spent lead-acid units accumulating in yards around the country.

The government, which secured a $250 million World Bank loan last year to rehabilitate the utility, has proposed a law that would allow households to sell surplus power to the grid and would license neighborhood microgrids. The bill has been in parliamentary committee since March. Energy ministry officials say the state’s priority is restoring its own plants; the utility’s two main stations have been operating at a fraction of capacity for want of maintenance and gas.

“The question is whether the state tries to rebuild the system it had, or accepts the one its citizens built in its absence,” said Dr. Karim Nassar, who teaches energy policy at the American University of Beirut. “Most countries spend a decade designing a distributed grid. Lebanon has one. It just needs to be told it exists.”

In Achrafieh, the building’s residents pooled $38,000 three years ago for a shared rooftop system and a battery bank in the basement. Their electricity costs have fallen to about $40 a month per apartment. The building’s concierge, Georges Khoury, 58, tends the panels with a hose. “We still have the generator in the parking garage,” he said. “We start it once a month, to make sure it works. It feels like visiting an old relative.”