Mexico City — Migrants fearing deportation, settting a mattresses ablaze at an immigration detention center in Mexico, starting a fire that left 39 dead, Mexico’s president said Tuesday.

It was one of the the deadliest incidents ever at an immigration lockup in the country.

Hours after the fire broke out late Monday, rows of bodies were laid out under shimmery silver sheets outside the facility in Ciudad Juarez, which is across from El Paso, Texas, and a major crossing point for migrants. Ambulances, firefighters and vans from the morgue swarmed the scene.

Thirty-nine people died and 29 were injured and are in “delicate-serious” condition, according to the National Immigration Institute. There were 68 men from Central and South America held in the facility at the time of the fire, the agency said.

President Andrés Manuel López Obrador called the incident unfortunate and said the director of country’s immigration agency was on the scene.

“They never imagined that this would cause this terrible misfortune,” López Obrador said.

Tensions between authorities and migrants had apparently been running high in recent weeks in Ciudad Juarez, where shelters are full of people waiting for opportunities to cross into the U.S. or who have requested asylum there and are waiting out the process.

More than 30 migrant shelters and other advocacy organizations published an open letter March 9 that complained of a criminalization of migrants and asylum seekers in the city. It accused authorities of abuse and using excessive force in rounding up migrants, complaining that municipal police were questioning people in the street about their immigration status without cause.

The high level of frustration in Ciudad Juarez was evident earlier this month when hundreds of mostly Venezuelan migrants acting on false rumors that the United States would allow them to enter the country tried to force their way across one of the international bridges to El Paso. U.S. authorities blocked their attempts.

The national immigration agency said Tuesday that it “energetically rejects the actions that led to this tragedy” without any further explanation of what those actions might have been.

In recent years, as Mexico has stepped up efforts to stem the flow migration to the U.S. border under pressure from the American government, the agency has struggled with overcrowding in its facilities. And the country’s immigration lockups have seen protests and riots from time to time.

Mostly Venezuelan migrants rioted inside an immigration center in Tijuana in October that had to be controlled by police and National Guard troops. In November, dozens of migrants rioted in Mexico’s largest detention center in the southern city of Tapachula near the border with Guatemala. No one died in either incident.