Six months ago, I was in the National Museum in Beirut, marvelling at two Phoenician sarcophagi among the treasures from ancient Middle Eastern civilizations, when the lights suddenly went out. A few days later, I was in the Bekaa Valley, whose towns hadn’t had power for half the day, as on many days. More recently, I was in oil-rich Iraq, where electricity was intermittent, at best. “One day we’ll have twelve hours. The next day no power at all,” Aras Maman, a journalist, told me, after the power went off in the restaurant where we were waiting for lunch. In Egypt, the government has appealed to the public to cut back on the use of light bulbs and appliances and to turn off air-conditioning even in sweltering heat to prevent wider outages. Parts of Libya, which has the largest oil reserves in Africa, have gone weeks without power this year. In the Gaza Strip, two million Palestinians get only two to four hours of electricity a day, after yet another cutback in April.

The world’s most volatile region faces a challenge that doesn’t involve guns, militias, warlords, or bloodshed, yet is also destroying societies. The Middle East, though energy-rich, no longer has enough electricity. From Beirut to Baghdad, tens of millions of people now suffer daily outages, with a crippling impact on businesses, schools, health care, and other basic services, including running water and sewerage. Little works without electricity.

“The social, economic and political consequences of this impending energy crisis should not be underestimated,” the U.N. special coördinator for the Middle East peace process, Nickolay Mladenov, warned last month, about the Gaza crisis. The same applies across the region.

Public fury over rampant outages has sparked protests. In January, in one of the largest demonstrations since Hamas took control in Gaza a decade ago, ten thousand Palestinians, angered by the lack of power during a frigid winter, hurled stones and set tires ablaze outside the electricity company. Iraq has the world’s fifth-largest oil reserves, but, during the past two years, repeated anti-government demonstrations have erupted over blackouts that are rarely announced in advance and are of indefinite duration. It’s one issue that unites fractious Sunnis in the west, Shiites in the arid south, and Kurds in the mountainous north. In the midst of Yemen’s complex war, hundreds dared to take to the streets of Aden in February to protest prolonged outages. In Syria, supporters of President Bashar al-Assad in Latakia, the dynasty’s main stronghold, who had remained loyal for six years of civil war, drew the line over electricity. They staged a protest in January over a cutback to only one hour of power a day.

Over the past eight months, I’ve been struck by people talking less about the prospects of peace, the dangers of ISIS, or President Trump’s intentions in the Middle East than their own exhaustion from the trials of daily life. Families recounted groggily getting up in the middle of the night when power abruptly comes on in order to do laundry, carry out business transactions on computers, charge phones, or just bathe and flush toilets, until electricity, just as unpredictably, goes off again. Some families have stopped taking elevators; their terrified children have been stuck too often between floors. Students complained of freezing classrooms in winter, trying to study or write papers without computers, and reading at night by candlelight. The challenges will soon increase with the demands for power—and air-conditioning—surge, as summer temperatures reach a hundred and twenty-five degrees.

The reasons for these outages vary. With the exception of the Gulf states, infrastructure is old or inadequate in many of the twenty-three Arab countries. The region’s disparate wars, past and present, have damaged or destroyed electrical grids. Some governments, even in Iraq, can’t afford the cost of fuelling plants around the clock. Epic corruption has compounded physical challenges. Politicians have delayed or prevented solutions if their cronies don’t get contracts to fuel, maintain, or build power plants.

The movement of refugees has further strained equipment. Lebanon, Jordan, Iraq, and Egypt, already struggling, have each taken in hundreds of thousands of Syrian refugees since 2011. The frazzled governor of Erbil, Nawzad Hadi Mawlood, told me that Iraq’s northern Kurdistan—home to four million Kurds—has taken in almost two million displaced Iraqis who fled the Islamic State since 2014, as well as more than a hundred thousand refugees fleeing the war in neighboring Syria since 2011. Kurdistan no longer has the facilities, fuel, or funds to provide power. It averages between nine and ten hours a day, a senior technician in Kurdistan’s power company told me, although it’s worse in other parts of Iraq.

I called on the technician at his home because electricity is now such a political flashpoint that he didn’t want to be seen hosting a journalist at work. Dusk was settling in so the living room was poorly lit. His house had no electricity, either. The only thing that worked was a wall clock. “It’s battery-operated,” he told me. I asked if he knew when electricity would return. He shrugged. “When you see the lights go on,” he replied. “I only work for the power company. They don’t tell us the hours, either.”

In Erbil, as in cities across the Middle East and North Africa, the only alternatives are noisy and polluting generators that cost three to ten times state rates. “I have no generator,” the technician noted.

In Lebanon, Moustafa Baalbaki, a young software engineer, tried to help people cope with outages by developing the cell-phone app Beirut Electricity, which does what the government doesn’t: it forecasts power cuts in the capital—and sends alerts ten minutes before the power goes out.

“I spent days and nights vainly wishing for the government to fix this problem,” Baalbaki told me. He originally figured out the complicated algorithm to plan his university classes and figure out when his ailing grandmother could visit so she could take the elevator to the family’s ninth-floor apartment. It worked so well that he offered it free to other Lebanese through Apple. It had almost ten thousand downloads the first day.

“The government doesn’t like me much,” Baalbaki told me. “I’m really not in competition. I’m just trying to find solutions that make life tolerable in these conditions. It’s terrible that we live like this in 2017. I’d be happy to kill the app—if we’d just get twenty-four hours of electricity.”