CASABLANCA, MOROCCO
— Each Friday, dozens of people gather for the Friday prayer at the mosque of Derb Ghellef, a popular district in Casablanca. Not far away, a couple of itinerant sellers display computer software and CDs of recorded sermons.

"We mostly sell Egyptian and Saudi CDs," says a young seller. "What we are selling is forbidden, but if we see the police coming, we pack up everything."

Six months after religious extremists carried out five suicide attacks in Casablanca, Moroccan authorities are struggling to regain control of the mosques and, more important, of religious theorists in the country.

The Salafia Jihadia, the terrorist organization responsible for the attacks - which killed 45 people - was formed by former mujahideen fighters after their return from Afghanistan. It draws its spiritual doctrine from the Wahhabi branch of Islam, the state religion in Saudi Arabia.

"May 16 pushed the state to break with Wahhabism," says Prof. Mohamed Darif, a specialist on Islam.

But even though jihadists are banned by the government, it will prove difficult to prevent radical preachers from spreading their theories. In a crowded market in Rabat, the CDs of Wahhabi Sheikh Mohamed Al Arifi, who spoke of an Islamic conquest of the Vatican, and Sheikh Zendani are still on sale.

"We can sell pretty much anything we want," says a young woman. "Controllers come to check what is on sale, but they don't give us any instruction. There is not much they can do; everything can be found on the Internet and on satellite TV."

Indeed, controversial religious theorists use the latest technology to spread their ideas to an increasingly conservative and religious youth. The success of the Saudi-owned and Wahhabi-influenced TV channel Iqraa underscores the popularity of conservative preachers.

Wahhabi theorists, who endorse a rigorous, fundamentalist interpretation of Islam, reject other forms, like the open Malikism of Morocco. They also describe Shiites as apostates.

The introduction of Wahhabism to Morocco dates to the 19th century, but it remained marginal. "Wahhabism existed, but it did not benefit from the support of the state until 1979," says Mr. Darif.

After the 1979 Iranian revolution, the Wahhabi doctrine was key in preventing the spread of the Shiite revolution to Morocco. At that time, Moroccan authorities were also facing the rise of political Islam, also at odds with traditional Wahhabism. "The Iranian revolution led the state to rethink its mechanisms to face political Islam," says Darif. "Wahhabism delegitimates both [political Islam] and Shiites."

Strengthened by the oil boom of the 1970s, Saudi Arabia sponsored Wahhabi religious schools and distributed scholarships and religious literature to hundreds of students. The schools attracted students from the rest of the Arab world, and hundreds of Wahhabi-trained preachers returned home to spread their theories.

Morocco was also receiving much-needed financial help from Saudi Arabia to support its military effort in the western Sahara, a territory disputed by Morocco and the Polisario, a rebel independence movement. "When Saudi Arabia gave money [to Morocco], it had to welcome its ulemas [theorists]. There was a political price to pay," says Darif.

It is only recently, however, that the Wahhabi movement split (both in Saudi Arabia and Morocco), with a new politically driven and violent wing emerging that urges jihad against the West and its allies.

According to Islam expert Mohamed Tozy, the main difficulty for Moroccan authorities was to control imported radical religious doctrines. Before the globalization of radical Islam, with the return of former Afghan fighters and of controversial religious theorists, the state had "the monopoly of the production of religion."

But radicals started to condemn prayers in state-controlled mosques, and distributed pamphlets and tapes denouncing the "infidel" state and the religious status of the king - once seen as a bulwark against extremism - in "garage mosques."

Among them were Abou Hafs, who studied in Saudi Arabia, and Hassan Kettani, two young preachers with numerous sympathizers who were arrested before the bombings and later sentenced to 30 and 20 years in prison, respectively. Authorities said they were the "ideologists" of the Salafiya Jihadia, the terror group.

The shift in the state's religious policy started after Sept. 11, 2001, well before the May bombing. In summer 2002, Al Qaeda-linked terror cells planning attacks across the country were discovered and several religiously motivated crimes were attributed to Salafia Jihadia.

But while local Islamist leaders have often distanced themselves from Wahhabis, some still deny the damaging influence of the Saudi Arabian export. "It's not Saudi Arabia that created poverty and slums. This created a favorable environment for extremism," says Abdesslam Balaji, a leader of the Movement of Unification and Reform, an official Islamist group.