Around 50,000 migrants crossed into Spain’s North African exclave of Ceuta this week, a mass influx that overwhelmed local authorities. At least 57 people died during the crossings, which prompted tighter border security measures across Europe.

Spanish leaders said they were working to expel all those who had entered as quickly as possible, and said by Friday evening that most migrants had been returned to neighboring Morocco. Many had returned voluntarily after failing to find food or shelter in Ceuta. However, the causes of the surge remain disputed.

Spanish officials including Prime Minister Pedro Sánchez said human trafficking networks encouraged the crossings, by misrepresenting a recent Supreme Court ruling on migrant returns.

According to that explanation, the traffickers and migrants incorrectly assumed that the ruling meant anyone attempting to enter by sea could not be deported. However, the legal decision was extremely narrow.

On June 29, Spain’s Supreme Court issued a ruling stating that authorities cannot summarily deport migrants who arrive by sea without due process, because they did not cross the physical border infrastructure referenced in Spanish law.