JERUSALEM — Like many things, social distancing is a luxury unavailable to the residents of al-Shati, a refugee camp in the northern Gaza Strip. Almost 86,000 Palestinians, living sometimes 12 to an apartment, are packed within a quarter-square-mile of density and despair ready made for a coronavirus explosion.

“If the virus reaches us, many people will die,” said Mahmoud Shakshak, 65, an unemployed al-Shati resident. “Not just because of the virus, but because the world will close to us and they will let us die alone.”

For residents and health officials alike, the prospect of a ­covid-19 outbreak within one of the dozens of refugee camps, migrant centers and displacement sites spread across the Middle East is a nightmare within a nightmare. Agencies are bracing for the rapid spread of the disease through tightly packed camps where feeble health systems, poor sanitation, warfare and political restraints could make it nearly impossible to contain.

In Yemen, nearly 3.6 million people are displaced from their homes, the vast majority living in makeshift camps with meager facilities or in overcrowded neighborhoods in the capital, Sanaa, Aden and other cities.

Nearly 900,000 Libyans forced by fighting to shelter in schools and other temporary centers are in need of humanitarian assistance, according to the United Nations. Some 1,800 mostly African migrants are held under brutal conditions in state-run, overcrowded detention centers with a lack of access to sanitation facilities, food or clean water.

In Iraq, humanitarian groups say they fear for the 1.5 million civilians displaced in battles to defeat the Islamic State. Packed across camps or cramped apartment blocks, many have limited access to food. What clean water they have is needed for cooking, not hand-washing.

In all countries of the region, overcrowded prisons are a major worry, as illnesses typically spread like wildfire through cells crammed beyond capacity.

“The detainee population is particularly vulnerable to infectious diseases,” said James Matthews, a spokesman for the International Committee of the Red Cross in Iraq. He said that the organization had distributed hygiene kits among the country’s prisons in recent weeks.

War-shattered Syria is perhaps the biggest concern, particularly the northwest of the country where fighting continues between government forces and rebels despite a fragile cease-fire. Nearly 4 million people, most of them displaced from elsewhere in the country, are crammed into a sliver of territory along the Turkish border, which has surpassed Gaza as the most densely populated part of the Middle East.

Overall, 11 million Syrians have been displaced by the nine-year war, half inside Syria, half living as refugees across the Middle East, including in Turkey, Jordan, Iraq, Egypt and particularly Lebanon. All are vulnerable to the worst effects of the pandemic.

“When the virus hits overcrowded settlements in places like Iran, Bangladesh, Afghanistan and Greece, the consequences will be devastating,” Jan Egeland, secretary general of the Norwegian Refugee Council, said this week. “There will also be carnage when the virus reaches parts of Syria, Yemen and Venezuela, where hospitals have been demolished and health systems have collapsed.”

Health experts hope that the relatively young average age of the displaced will help keep the death rate low. (In some centers, more than 60 percent are children.) And for now, no camp outbreaks have been reported. In some cases, the camps’ very isolation may be slowing the appearance of the virus within their fences and walls.

Access to Gaza, for example, is tightly controlled by Israel, which has largely sealed the enclave’s crossings to Israel and Egypt. Aid workers there are using the time to prepare for what they view as the virus’s inevitable arrival.

“There is no reason to believe the virus will detour around Gaza,” said Gerald Rockenschaub, head of World Health Organization operations within the Palestinian territories. “We have to be ready.”

The Palestinian Ministry of Health is focused on an aggressive program of isolation to keep the virus from gaining a foothold in the enclave of 2 million people and eight refugee camps. Without enough kits to test all arrivals, anyone returning from outside — at this point, mostly patients who had been seeking non-coronavirus-related medical treatment in Israel — is quarantined for two weeks within converted clinics, schools and hotels.

If an outbreak does begin, Gaza, which suffers daily rolling blackouts and unsafe drinking water, is ill-equipped to respond. There are only 60 intensive-care beds in the territory, 70 percent of which are in use. Officials have built an emergency 38-bed field hospital. But efforts to bring in supplies are faltering as borders close around the region. The WHO’s normal two-day supply route from Dubai via Jordan now takes two weeks. Supplies of vital equipment, particularly respirators, are hampered by collapsing global supply chains.

“We had gotten respirators from Italy, but now we cannot,” said Abdel Nasser Soboh, the WHO’s Gaza chief.

In all the camps, slowing the spread will be critical. Gaza could handle 300 cases in three months, Soboh said, but not 300 cases in a week.

“That is when we might get to a state where a doctor has to decide who lives and who dies,” he said.

The region’s legacy of war, with the fighting still raging in many spots, means that health and humanitarian workers have little to work with as the virus advances.

Yemen, at war for more than five years, has seen its health infrastructure collapse. Scores of hospitals and clinics have been destroyed by airstrikes. An air and sea embargo imposed by the Saudi-led coalition of regional nations, which is battling northern Yemeni rebels known as Houthis, has helped cause shortages in medicines, medical equipment and other vital health supplies for millions of Yemenis.

Between March 2015 and December 2018, Yemen’s warring parties have staged at least 120 attacks on medical facilities and health workers, according to a report released Wednesday by the New York-based Physicians for Human Rights and Mwatana for Human Rights, an independent Yemeni group.

Flight bans and closed crossings have raised concerns that coronavirus measures could themselves disrupt ongoing humanitarian relief efforts in a country described by the United Nations as the world’s worst humanitarian catastrophe, where at least 10 million are one step away from famine.

Humanitarian agencies have scaled back their teams to essential staff and medical evacuations have been halted, according to the New Humanitarian, a news service focused on relief efforts.

The United Nations on Tuesday appealed for humanitarian agencies not to allow the coronavirus to interrupt the vital work that sustains the needs of 100 million vulnerable people worldwide who are dependent on the delivery of U.N. aid.

In Lebanon, Syrian refugees are ineligible for government health care, meaning a covid-19 outbreak would leave them without care.

Along Syria’s border with Turkey, the WHO is “extremely concerned” about the impact the coronavirus will have on displaced populations, said Hedinn Halldorsson, the WHO’s representative in Gaziantep, Turkey.

People in the area are already living in appalling conditions that “make them vulnerable to respiratory infections, overcrowded living conditions, physical and mental stress and deprivation due to lack of housing, food and clean water.”

Specimens from suspected cases are being transported across the border to be tested in Turkey, he said. But covid-19 kits are expected to arrive next week in Idlib, where an outbreak of the H1N1 virus is already taxing resources.

The area has just 148 intensive-care units and 153 ventilators, he said. Should the virus become established in a place so primed for it to spread aggressively, they will not be enough.

Another camp where an outbreak of the coronavirus could be devastating is al-Hol in northeast Syria, where 65,000 people who fled the final battles against the Islamic State are living in what amounts to a tented prison in the desert. There are no testing facilities in the Kurdish-controlled enclave where the camp is located and few facilities to cope with any outbreak. But the remote camp would be especially hard hit because it offers only the most basic medical care, aid workers say.

Loveluck reported from London. Liz Sly in Beirut, Sudarsan Raghavan in Cairo and Hazem Balousha in Gaza contributed to this report.