The maritime law concept of "innocent passage" allows foreign vessels to transit through a coastal state's territorial waters. This is the legal basis Morocco invokes in incidents such as that of 30 July and for the presence of Moroccan ships while the mass influx of migrants at the Ceuta border was under way.
This concept is governed by the United Nations Convention on the Law of the Sea. In fact, until 30 July Spain monitored these movements without intervening, but the situation has changed since the last two days of July.