Morocco says it has dismantled an ISIL cell plotting to launch attacks across the country after security forces conducted operations in a number of cities, including Marrakesh.

Authorities say the men, aged between 19 and 37, were planning to kill public and military figures.

“The cell was holding a dangerous terrorist plan and was ready to endanger the country's safety and security," Reuters news agency quoted Abdelhaq Khyam, head of the Central Bureau for Judicial Investigations, as saying.

In addition to Sunday's arrests, police say they confiscated handguns, ammunition, mobile phones and computers.

"We learnt that they gave their allegiance to the Islamic State in Iraq and the Levant (ISIL) [group] and to [Abu Bakr] Baghdadi to the extent that they called their cell Wilaya of the Islamic State in the Far Maghreb," Khyam said.

The group is also suspected of recruiting people to fight in Iraq and Syria for ISIL.

According to authorities, 1,354 Moroccans are believed to have joined ISIL to fight in Syria and Iraq, of which 156 have returned to Morocco.

At least 246 of them have been killed in Syria and another 40 have died in Iraq, according to Khyam, who added that 185 Moroccan women had joined the group, along with 135 children.

Weapons smuggling

The group is alleged to have obtained its weapons through the Spanish enclave of Melilla on the state's northern coast.

Spanish and Moroccan security forces have been working together to dismantle smuggling networks based in their respective territories, and to dismantle ISIL recruitment cells.

The men, who were mostly apprehended in the city of Agadir on Morocco’s western coast, had not trained abroad but were in “permanent” contact with ISIL leaders, according to Khyam.

Part of their plan included attacking soldiers to acquire better weapons then decapitating and burning them, the AP news agency reported

Like in Tunisia, many young, disaffected Moroccans have sought to travel abroad to join ISIL in Syria and Iraq.

Last week an attack claimed by ISIL in Tunisia killed 21 people, mostly foreign tourists.