Rabat: Morocco, on guard against attacks like the Tunis museum massacre, prides itself on being a bastion against Islamist extremism with its anti-jihadist "FBI" and training of imams to preach tolerance.
More than 130 "terrorist cells" have been dismantled, 2,720 suspects arrested and 276 plots foiled since 2002, according to Abdelhak Khiame, director of the newly established Central Bureau of Judicial Investigations.
Dubbed Morocco`s FBI, the Bureau announced this week it had broken up a 13-member cell that pledged allegiance to the Islamic State (IS) jihadist group and operated in about a dozen cities across the country.
The bust came just days after jihadists gunned down 20 foreign tourists and a policeman at the Bardo National Museum in Tunisia in an attack claimed by IS.
Morocco is in a state of "constant high alert", according to government spokesman Mustapha Khalfi.
Tarik Tlaty, head of the Moroccan Centre of Strategic Studies and Research, said the country is "the most stable in the region", thanks largely to the fact that it does not border anarchy-wracked Libya.
Its expertise in combating radical Islam dates back to the 1990s when Moroccans fought in Afghanistan, said Louis Caprioli, a former counter-terrorism chief at French intelligence agency DST.
Manar Slimi, who heads the Maghreb Centre for Security Studies and Policy Analysis, said Rabat had built up "a complete database" which it shares with Western allies.
Following the Islamist attacks in Paris that left 17 people dead in January, France and Morocco resumed judicial cooperation after a year-long row.
Rabat had suspended cooperation with Paris in February 2014 after French authorities tried to question the head of Morocco`s DGST domestic intelligence service over torture allegations.As part of its security strategy, Morocco in 2008 launched a vast reform programme to train its imams who lead prayers in mosques, with a budget of almost 20 million euros ($22 million).
The aim has been to promote a tolerant and non-violent form of Islam based on Morocco`s official Maliki school of Sunni Islam.
A spate of suicide bombings on May 16, 2003 in the city of Casablanca that left 33 dead marked a turning point.
Several preachers were rounded up in sweeping arrests which followed, including Mohamed Fizazi, an Islamic scholar considered a jihadist-salafist.
A "reformed" Fizazi was granted a royal pardon during Arab Spring protests in 2011 and last year led a session of prayers in King Mohammed VI`s presence at which he stressed "the importance of security and stability in the exercise of faith".
But Morocco has not escaped unscathed in recent years: a 2011 cafe bombing in Marrakesh killed 15 people, including eight French tourists.
And with close to one in three young Moroccans unemployed, up to around 2,000 of its nationals are thought to have joined the ranks of jihadists including IS fighting in Iraq, Syria and Libya.
Despite its successes, "no country is immune" to extremism, said Slimi.