With substantial numbers of Moroccans joining jihadist groups abroad, the government is wary of a blowback from these fighters returning home
More than 3,000 Moroccan jihadists are said to be in Syria and Iraq. They may account for 10 per cent of all foreign militants fighting the Al-Assad regime and are reported to be the second-most numerous nationality among the heavily armed forces of the Islamic State in Iraq and Syria (Isis).
While such figures can only be estimates, there is no doubt violent jihadism has attracted substantial numbers of recruits from Morocco, despite the countrys long tradition of religious moderation and the political prominence of the Islamist Justice and Development Party (PJD), which currently leads the government.
The attraction of international jihad for a significant number of young Moroccans is an additional major concern for the authorities, who have for many years worked to contain the danger posed by domestic terrorist cells.
Bomb attacks in Casablanca in 2003 and 2007 and Marrakesh in 2011 not only caused human suffering, but also frightened away foreign tourists, who are an important source of income and employment.
Now the authorities in Rabat are faced with the potential blowback of fighters returning home from conflicts in Syria and Iraq, and also Mali, where jihadists occupied the north for nine months in 2012-13 before being expelled by French and African forces.
There is concern that veterans of these foreign wars will return home with their ideological convictions hardened and their military skills enhanced, a potential reservoir of battle-trained recruits for the terrorist groups that have staged occasional attacks in Morocco itself.
The government has stepped up security controls in response. But there is a recognition that policing and intelligence can only be part of the answer.
Islam enjoys a role at the heart of the political mainstream graphically illustrated by the US president and first ladys warm Washington welcome this month for PJD prime minister Abdelilah Benkirane and his wife. And back home in government, the premier has stepped up efforts to tackle social and economic issues.
Moroccan Islam is moderate and pluralistic. King Mohamed VI responded to protests in 2011 with steps to reinforce democratic institutions and political choice. The country has attracted job-creating capital investment and has worked hard to tackle housing shortages.
And yet significant numbers of young men have still been attracted by the prospect of fighting in foreign wars in the name of radical jihadism and against enemies who have no connection to the Moroccan context: Iraqi Shias; the authoritarian regime of Syrias President Bashar al-Assad; and the Iraqi Kurds.
There is a recognition of the need to ease the social pressures that could foster [discontent] among urban youths
In April, the Moroccan government estimated that 1,500 of its citizens were fighting in Syria, and in July, Mohamed Hassad, the interior minister, put the number of Moroccan jihadists in Syria and Iraq at more than 3,000, although he added that close to 2,000 are in fact European residents of Moroccan descent. These figures tally with a new report from Soufan Group, a US-based security specialist. Some reports suggest about 400 Moroccans have been killed fighting in Syria since 2011.
High-profile individual cases include Mohamed Hamdouch, notorious for beheading captives in Syria, and a 13-year-old boy, Ouassama Chaara, who recently returned to Morocco after a spell with Syrian jihadists.
Hassad has explained that the authorities are particularly worried about individuals of Moroccan descent with European nationality because they can travel more freely on their EU passports.
He said that five known Moroccans are members of the leadership of Isis and the government has recently discovered networks recruiting volunteers for the war in Syria and Iraq. The minister said 128 jihadists were arrested on their return home, while several dozen other returnees were halted at the frontier between Syria and Turkey.
A French-Moroccan was arrested on 2 August at Charles de Gaulle airport in Paris, on his return from Turkey, four days after the detention of a French citizen of Algerian descent at Tanger-Med port.
Last year, the authorities arrested members of cells in Nador trying to recruit youths to fight in northern Mali, where Al-Qaeda in the Islamic Maghreb (AQIM) is still active despite a French-led intervention to end the 2012-13 jihadist occupation. The government fears AQIM could foment attacks in Morocco itself.
The nervous mood has been highlighted by terrorism incitement and support charges controversially brought against the journalist Ali Anouzla who frequently covers corruption allegations after the news website Lakome reported on an AQIM video diatribe against Morocco, with a link to the site of the Spanish newspaper El Pais, where it could be viewed.
Hassad says that the country faces a real terrorist threat. The authorities have issued an orange level terrorism alert about the risk of attacks on restaurants with US brand names. France and the UK have also warned their citizens about terrorism risk in Morocco.
At the US-Africa summit in Washington in early August, the Moroccan and US governments inked a security cooperation agreement. To help counter the AQIM threat, the US will train Moroccan specialists.
Regional arrangements in north and west Africa coordinate action against the jihadist threat, although Moroccos participation in some initiatives is hindered or blocked by the poor state of relations with Algeria.
As a consequence, Morocco is not a member of the Nouakchott process of intelligence and political cooperation launched in March 2013, in which Algeria plays a big role. However, it is included in the UNs strategy for the region, which is coordinated by the UN office in Dakar, Senegal.
In addition, King Mohammed and the government have put substantial effort into building strong bilateral ties with West African countries, including on security issues.
Mali has been a particular focus, with visits by the king in September 2013 and again in February. King Mohamed is offering discreet support to the peace talks between the Mali government and northern non-jihadist rebel groups, and Rabat has agreed to train 500 Malian imams in the moderate Moroccan tradition of Islam.
Meanwhile, at home, the authorities have launched a multi-pronged strategy to counter jihadist terrorism and weaken its potential appeal to the disenchanted.
Security measures inevitably play a key part, particularly in countering the most immediate threats, with the key roles falling to the national police service, La Direction Generale de la Surete Nationale and the security service, La Direction Generale de la Surveillance du Territoire.
But longer-term policies are aimed at reshaping the wider environment and target sources of discontent, social attitudes and other factors that influence the climate in which some people might otherwise be drawn to radical ideas.
There is a recognition of the need to ease the social pressures that could foster disenchantment among low-income urban youths.
Morocco, like other Maghreb countries, has high levels of youth unemployment. But job creation, through a broad range of economic policies and investment promotion, is inevitably a gradual process.
The other key strand of policy is to promote the countrys distinctive tolerant tradition of Malekite Islam.
The king is recognised as a religious authority in Morocco and during Ramadan, which ended in early August, he called on imams to preach a peaceful version of Islam. The Ministry of Religious Affairs has developed a programme to educate almost 50,000 imams, reinforcing this agenda.
Non-violent Moroccan Islam and the moderate Islamist PJD, which governs in coalition with secular parties, have been the target of virulent online criticism by supporters of militant groups such as Isis. Such critics are trying to stir up support for violent revolutionary jihadism and potential terrorist action in Morocco itself.
But King Mohammed and the government have also sought to mobilise the influence of former terrorists against an upsurge in radicalism.
The king has granted clemency to Salafists who had been serving jail terms in connection with the 2003 bombings in Casablanca, including Omar Haddouchi, who used to belong to Salafia Jihadia. The now-freed Salafists have spoken out against the involvement of young Moroccans in the Syrian conflict, drawing on religious texts to support their arguments.
Former radicals are seen by the king as important counterweights to the influence of the advocates of violent jihad, such as Mejjati.
In July, Haddouchi issued a comment seeking to show, through theological arguments, that declaring allegiance to Isis self-proclaimed caliph Abu Bakr al-Baghdadi would be illegitimate.
He quoted a hadith of the Prophet Mohammed that says anyone pledging allegiance to a stranger without approval from, or consultation with, the entire Muslim community, is eligible for the death penalty.
Isis hit back with a video attacking both Haddouchis view and the PJD and its justice minister, Mustapha Ramid.
The group tends to attack moderate Islamists in Morocco on religious grounds in contrast with the line taken by AQIM, which criticises King Mohammed for his liberal ruling style.
While AQIM has primarily gone after the non-Islamist, modern Moroccan monarch, [Isis] has levelled criticism against Islamists first, portraying them as insufficient, inauthentic, even kuffar [infidels], says Vish Sakthivel, a fellow at the Washington Institute for Near East Policy.
King Mohammed and the government now have to work out how far to rely on conventional strategies to counter the influence of international jihadism and how far the monarch will be able to draw on his religious authority in Morocco to eradicate extremism.
The kings response will be telling on two fronts: how Rabat positions itself as a regional political authority, and whether it deepens its use of symbolic/rhetorical tools in countering extremism at home, says Sakthivel. The kings recent decision to bar religious leaders from participating in any form of political or union activity may be indicative of the latter.
In July, the goverment put the number of Moroccan jihadists in Syria and Iraq at more than 3,000