"The Spanish government, while being committed to defending the rights of its nationals abroad, reiterates the need to abide by the law in force," the Spanish Foreign Ministry said in a statement.
Spain's Foreign Minister Miguel Angel Moratinos made contact with his Moroccan counterpart Taib Fassi Fihri on this matter, the statement said.
Spanish State Secretary to Foreign and Latin-American affairs Juan Pablo de Laiglesia had also a telephone conversation with Moroccan Secretary General to the Foreign Ministry, Youssef Amrani, it added.
The Moroccan authorities, the statement went on to say, explained that "the Spanish activists took part in an illegal and unauthorized demonstration during which protesters and Moroccan citizens clashed."
The Moroccan authorities' intervention was meant to stop these clashes, it said.