Two primary historical drivers brought Islam to large parts of Africa:
Muslim merchants from North Africa and the Middle East traversed the Sahara, exchanging salt, textiles, and manufactured goods for West African gold, ivory, and slaves. Along these routes—linking cities like Sijilmasa, Awdaghost, Timbuktu, Gao, and Kano—Islam spread organically through:
Result: The great Sahelian empires—Ghana, Mali, Songhai—became Muslim polities, with Islam as the state religion and Arabic as the language of administration and learning.
Arab armies expanding westward from Egypt conquered the Byzantine-held Maghreb (modern Libya, Tunisia, Algeria, Morocco) between 642 and 709 CE. The indigenous Berber (Amazigh) populations were incorporated—sometimes by force, often through gradual assimilation—into the Islamic caliphate. Conversion was incentivized by tax policy (jizya vs. zakat) and social mobility.
From this North African base, Islam later crossed the Sahara (see #1) and, centuries later, the East African coast via Indian Ocean trade.