This is Tajoura detention center in Libya. It was sheltering hundreds of African migrants and refugees when it was hit by an airstrike on July 2. The attack killed at least 53 people and wounded many more. How could something like this happen to a migrant holding center? The Times analyzed photos, videos, and satellite images of the facility. And former detainees and humanitarian observers in Libya told us grim stories of lapses on many fronts. Anti-government forces vying for control in Libya carried out this airstrike. But the attack has shed new light on a simple fact: Thousands of migrants are now trapped in the crosshairs of a brutal civil war between the Libyan government and those rebels. And it exposes serious failures on the part of the European Union, which has outsourced some of its migration problems to a country in chaos. The E.U. declined our interview requests and pointed to statements calling for an investigation, and for migrants to be moved. Libya has become a crossroads for Africans fleeing turmoil at home and trying to cross the Mediterranean to Europe. But the European Union has looked to Libya to prevent them from making the journey. It has given hundreds of millions of dollars to the Libyan Coast Guard and agencies supporting detention centers like the one in Tajoura. Overcrowding and lack of medical care in the centers has caused widespread health problems, experts say. “All these detention centers in Libya — they were built as warehouses. It’s just, they’ve now been repurposed for — instead of storing goods, they’re storing people.” And those who complained were often threatened by guards and militias that control those centers. The dire conditions inside the facilities are made even worse by what’s going on outside. The most serious issue we’ve uncovered is that the Tajoura center is located in a military compound. And the migrants’ living quarters are less than 100 yards from what our reporting shows is a weapons depot. We can confirm that these trucks with heavy weapons were photographed inside it. Migrants have told us they were forced to work in this depot cleaning and maintaining weapons for a pro-government militia that effectively controls the compound. Others say, the militia forced them to take up arms. This weapons depot is key, because on July 2 it was clearly targeted by the rebels. Images of the aftermath showed damaged military vehicles and the remains of an anti-aircraft gun. The nearby detention center was struck moments later. This security camera filmed what happened. First, the weapons depot was hit by an airstrike. Shrapnel is sent flying across the parking lot towards the migrant center. As smoke and debris spills out, people try to flee. But the guards stop them, witnesses told us. Then, 11 minutes later, a second airstrike hits the migrant detention center directly. Hundreds of people are confined inside. Some escape while others try to break through a locked door to the victims on the other side. These migrants were sitting ducks for rebel airstrikes and European officials should have known this. Why? Because some had visited the site. And the area had been targeted before. On May 7, an airstrike hit the very same weapons depot sending shrapnel through the roof of the migrant center. Two people were injured. And even before this, migrants in Libya tried to alert the public to the danger they were in. We obtained voice recordings from people being held in Tajoura and other centers. The U.N. refugee agency says it has tried to move migrants away from Tripoli. Italy is the only European country that took some migrants in. The ultimate blame for the attack on Tajoura lies with Khalifa Hifter, a Libyan strongman fighting to topple the U.N.-backed government in Tripoli. The U.N. says it shared. the center’s coordinates with his forces. But it didn’t matter. And the Tajoura strike may be far from the last. The U.N. says there are 3,800 refugees and migrants in Libya still being detained in areas of active clashes. Meanwhile, the survivors in Tajoura were released by the Libyan government on July 9. Some may be taken in by the U.N. But hundreds of others walked out onto the streets of an active conflict zone, uncertain of what lay ahead.