|Islam by country|
Islam is the largest religion in Morocco, with more than 99% of the population adhering to it. The largest subset of Muslims in Morocco are Maliki Sunni; other numerous groups include practitioners of Zahirism and non-denominational Muslims.
Islam was first brought to Morocco in 680 by an Arab invasion under the Uqba ibn Nafi, who was a general serving under the Umayyads of Damascus. In 788, The Shia Idrisids who espoused pro Zaydi views ruled large parts of Morocco. Their contemporaries included the heretical Barghawata state and the Khariji state of Sijilmasa. After several Berbers formed more powerful Islamic dynasties that reigned over the country. Among them were the Almoravids (1040–1147), who was the first to unite Morocco, as well as significant regions in West Africa, Spain and Algeria. The Almoravids were responsible for making the Malikii school of Islamic jurisprudence the most prominent in Morocco. It was later under Almohad rule (1121-1269) that smaller Muslim sects were persecuted and orthodox Sunni Islam became prevalent across the country.
In 2016, the government developed a strategy to further adherence to the Maliki Islamic school of thought. Religious education had textbook passages deemed promoting violence removed from the curriculum. As a result, religious textbooks had 24 lessons compared to the former 50.
According to Pew, 99% of Muslims in Morocco are Sunni predominantly of the Sunni Maliki madhab, or school of thought, whilst the remaining 1% adhere to other sects such as Shia, Quranism, ibadism etc. The administration of King Mohammed VI has combated the influence of Salafism via a state program where 100,000 imams will go to the country's 50000 mosques and promote the moderate Islam of the Maliki madhab. Morocco has a large Salafi movement, notable figures among it include Omar al-Haddouchi and Hassan Kettani. There are also adherents to the Quranist creed in Morocco, such as the author Rachid Aylal.[note 1] published a critical book on Bukhari's work in 2017, Sahih Al-Bukhari… The End of a Legend. It was banned in Morocco for disturbing spiritual security, purportedly due to pressure from Islamists.