RABAT - A Moroccan court sentenced a former Spanish soldier to eight years in jail on Friday on charges of leading an Islamist network in the kingdom that was plotting terror attacks, the state news agency MAP said.

Seventeen other members of the group, all believed to be Moroccans, were sentenced to between two and 10 years in prison on a variety of charges. The Spaniard was only identified by his initials - J.F. He was arrested in January 2014 and the Interior Ministry said at the time that he had served in Melilla, a tiny Spanish enclave on the Morocco’s Mediterranean coast. He resigned his commission and joined al Qaeda in Afghanistan where he learned guerrilla tactics, it said.

The authorities accused him of forming a criminal network with Moroccans drawn from numerous cities including Fes, Marrakesh and Nador, where he himself was based, near Melilla. No further details emerged from the trial and it was not clear if his organisation was affiliated to any particular Islamist group.

Morocco, a Western ally against Islamist militancy, regularly reports that has broken up radical cells accused of plotting attacks. On Thursday, the Interior Ministry said it had arrested three men seeking to join groups loyal to the Islamic State in Libya. The North African kingdom has suffered sporadic bomb attacks by suspected Islamist groups, most recently in 2011 in Marrakesh, but militant movements have so far failed to gain any foothold in the country.

Moreover, Eight Spanish police officers suspected of beating a Cameroonian migrant trying to enter the Spanish enclave of Melilla have been summoned to appear in court for questioning, officials said Friday.

The court in Melilla carrying out an investigation wants to ‘determine if the behaviour of the officers fell within the law,’ a court statement said. Video footage released by human rights group Prodein in October showed Spanish police officers beating a Cameroonian migrant with a truncheon and carrying him apparently unconscious back across the border to Morocco.

The man was one of about 100 migrants who tried to climb from Moroccan soil over a six-metre (20-foot) fence into the Spanish territory of Melilla. In the video, which caused outrage in Spain, an officer of the Spanish Civil Guard police force is seen hitting the 23-year-old man with a truncheon as he hung barefoot from the fence on the Spanish side.

The man is then seen dropping from the fence into the hands of a group of Spanish officers and lying on the ground. Spanish officers later carry him by the arms and legs as he lies limp, through a gate in the fence and back to the Moroccan side of the border. The officers who were summoned by the court face possible charges of failing to provide assistance to a person in danger, excessive use of force, assault and degrading treatment. Rights groups and the UN refugee agency have accused Spanish forces of violence towards migrants climbing the border fences into Ceuta and Melilla over recent months.

Spanish authorities ‘violate human rights with great violence. This must stop,’ Prodein spokesman Jose Palazon told AFP. Amnesty International welcomed the decision to summon the officers but a spokeswoman said the human rights group ‘regretted that the interior ministry did not launch any type of internal inquiry to put an end to these types of practices’. The Spanish territories of Melilla and Ceuta, both along Morocco’s Mediterranean coastline, attract thousands of people, mostly sub-Saharan Africans, trying to reach Europe. The migrants camp just outside both cities and frequently make mass attempts to climb their triple fences lined with razor wire or to swim along the coast.