A fading skirt of tawny light sets the city aglitter. The glare undulates for miles across the hillsides, touching cozy homes and glitzy high-rises and bullet-perforated storefronts. As the sky darkens, the Beirut power grid blossoms into a light show—flickering under the smallest of strains, at once beaming and struggling to burn, an electrical constellation to compete with the stars.

Below the hills of light there is one building whose marquee never dims or darkens. A large brutalist structure in the Mar Mikhael neighborhood of Lebanon's capital, the top floor is adorned with a white sign that seems to swallow all available surrounding light, stealing it from residential buildings nearby. On a clear night, the marquee shines through a nearby apartment overlooking the sea.

The Electricité du Liban building, in the Mar Mikhael area of Beirut, Lebanon. EDL has been able to offer electrical power only in bursts: Daily state-mandated power cuts run from at least three hours to 12 hours or more. Natalie Naccache

"If the Israelis come again, I hope they strike that building," Sam, the apartment's owner, says to me one evening. (His full name is withheld at his request because he fears legal trouble.) He points toward the imposing building, its windows filled with thrumming air conditioners. We are standing in Sam's apartment on a recessed central bay porch on the third floor of a qasr—a broad three-story residence overlooking the Mediterranean. Amid scattered beer cans and takeout bags on the balcony, Sam and a group of his friends maunder in the glare of the marquee during an electrical blackout.

One time, the marquee had broken and a single letter darkened, the missing Arabic character changing the meaning of the sign. "It once spelled 'Lebanese Bananas,'" he says. Given that the concrete building was the headquarters of Electricité du Liban, the state-owned power company and overseer of all things electric, to imagine one of the letters darkening is to fully realize the struggle over power (electrical, political, social) throughout Lebanon: Sometimes the lights do not stay on, even for the power company. Yet on this evening, the sign was glowing and the air conditioners below it were on, seemingly mocking the power outages elsewhere.

Electrical power here does not come without concerted exertion or personal sacrifice. Gas-powered generators and their operators fill the void created by a strained electric grid. Most people in Lebanon, in turn, are often stuck with two bills, and sometimes get creative to keep their personal devices—laptops, cell phones, tablets, smart watches—from going dead. Meanwhile, as citizens scramble to keep their inanimate objects alive, the local authorities are complicit in this patchwork arrangement, taking payments from the gray-market generator operators and perpetuating a nation’s struggle to stay wired.

Lebanon has been a glimmering country ever since the 15-year civil war began in 1975, and the reverberations from that conflict persist. These days there is only one city, Zahle, with electricity 24/7. Computer banks in schools and large air conditioners pumping out chills strain the grid, and daily state-mandated power cuts run from at least three hours to 12 hours or more. Families endure power outages mid-cooking, mid-washing, mid-Netflix binging. Residents rely on mobile phone apps to track the time of day the power will be cut, as it shifts between three-hour windows in the morning and afternoon, rotating throughout the week.

Once called the Paris of the Middle East, sometimes the region’s Sin City, Beirut’s supplementary power needs are effectively under the control of what is known here as the generator mafia: a loose conglomerate of generator owners and landlords who supply a great deal of the country’s power. This group is indirectly responsible for the Wi-Fi, which makes possible any number of WhatsApp conversations—an indispensable lifeline for the country’s refugees, foreign aid workers, and journalists and locals alike.

In Hamra, a popular tourist neighborhood in Beirut, about half of the buildings have diesel generators. Natalie Naccache

Electricité du Liban, the Lebanese electricity company, has a meager budget and relies on a patchwork approach—including buying power from neighboring countries and leasing diesel generator barges—to produce power; meanwhile, corruption in local and state politics means that government-allocated funds often do not reach the people or places for which they are intended. The community—or mafia—of generator owners is thus a solution to a widespread problem, and it has grown into a cottage industry, both intractable and necessary.