[3] Islam was first brought to Algeria by the Umayyad dynasty following the invasion of Uqba ibn Nafi, in a drawn-out process of conquest and conversion stretching from 670 to 711.
However, as in the Middle East itself, they sought to combine their new Islam with resistance to the Caliphate's foreign rule - a niche which the Kharijite and Shiite "heresies" filled perfectly.
By the late 8th century, most of Algeria was ruled by the Rustamids, who professed the strictly puritanical but politically moderate Ibadhi sect and saw the Caliphs as immoral usurpers.
They were destroyed by the Shia Fatimids in 909, but their doctrine was re-established further south by refugees whose descendants would ultimately found the towns of the M'zab valley in the Algerian Sahara, where Ibadhism still dominates.
With the political threat of the Abbasid Caliphate gone, these soon reverted to Sunni Islam - specifically, the Maliki branch, whose popularity had spread widely in the Maghreb.
The Fatimids took their revenge by sending the Bedouin Banu Hilal to wreak havoc on the region, but were incapable of controlling it; Shiism rapidly dwindled, and became virtually non-existent in the area.
During the Regency period, unlike the Maliki Algerian masses, the Ottoman-Algerians remained affiliated with the Hanifi school of Islamic jurisprudence.
Their attempts to rule the rest of the country met stiff opposition, often religiously inspired: the Sufi warrior Amir Abd al-Qadir was particularly notable for his campaign to keep the French out.
Much of the network of traditional Qur'anic schools and zaouias - regarded with suspicion as centers of potential resistance - collapsed, and the literacy rate fell.
Al Qiyam called for a more dominant role for Islam in Algeria's legal and political systems and opposed what it saw as Western practices in the social and cultural life of Algerians.
Chadli's regime was much more tolerant with Islamists, and with Algeria in the midst of an socio-economic crisis including unemployment and inflation, social tensions were high.
In recent years, the Civil Harmony Act and Charter for Peace and National Reconciliation have been passed, providing an amnesty for most crimes committed in the course of the war.
[9] The popularity of Islamism fluctuates according to circumstance; in the 2002 elections, legal Islamist parties received some 20% of the seats in the National Assembly, way down from the FIS's 50% in 1991.