More than 5,000 people were killed in Libya after torrential rains caused two dams to burst near the coastal city of Derna, destroying much of the city and carrying entire neighborhoods into the sea, local authorities said Tuesday.

Libya, a North African nation splintered by a war, was ill-prepared for the storm, called Daniel, which swept across the Mediterranean Sea to batter its coastline. The country is administered by two rival governments, complicating rescue and aid efforts, and despite its vast oil resources, its infrastructure had been poorly maintained after more than a decade of political chaos.

In the city of Derna alone, at least 5,200 people died, said Tarek al-Kharraz, a spokesperson for the interior ministry of the government that oversees Eastern Libya, according to the Libyan television station al-Masar. But the floodwaters also swept through other eastern settlements, including Shahhat, Al-Bayda and Marj, and at least 20,000 people were displaced.