Short answer
Islam reached Africa before it reached Madinah: around 615 CE early Muslims fled to Abyssinia (Ethiopia) and were protected by its Christian king. Egypt and North Africa came under Muslim rule in the first Islamic century, and Islam then spread south and east mostly through traders, scholars and Sufi teachers.
The accepted historical account is that Islam entered Africa in three ways: the migration to Abyssinia in the Prophet's ﷺ lifetime, the conquests of Egypt and North Africa under the Companions and the Umayyads, and centuries of peaceful spread through trade across the Sahara and along the East African coast.
The four schools agree on this.
Explanation
In the fifth year of prophethood, around 615 CE, a group of persecuted Muslims emigrated to Abyssinia on the Prophet's ﷺ advice, because its Christian king, the Najashi, was just. He protected them against Quraysh and later accepted Islam himself. When the Najashi died, the Messenger of Allah told the Companions in Madinah that a righteous man had died, and he led them in the funeral prayer for him in his absence.
Under Umar, Amr ibn al-As took Egypt around 20 to 21 AH (641 to 642 CE). Muslim armies moved west across North Africa over the next decades; Uqba ibn Nafi founded Kairouan in present-day Tunisia around 50 AH (670 CE). Conversion among Egyptians and Berbers was gradual, over generations. The Coptic church, for example, has continued in Egypt to this day.
South of the Sahara the story is mostly one of trade and teaching. Berber and Arab merchants crossed the desert with salt, gold and books, and West African kings and scholars took up Islam. See How did Islam spread in West Africa? On the east coast, traders from Arabia and Persia settled in ports such as Mogadishu, Kilwa and Zanzibar, and Swahili Muslim culture grew from that meeting.
Today Africa has hundreds of millions of Muslims, most of whom inherited Islam through peaceful contact. For the wider question, see Was Islam spread by the sword?
The evidence
Quran, Surah Saba 34:28
وَمَآ أَرْسَلْنَٰكَ إِلَّا كَآفَّةًۭ لِّلنَّاسِ بَشِيرًۭا وَنَذِيرًۭا وَلَٰكِنَّ أَكْثَرَ ٱلنَّاسِ لَا يَعْلَمُونَ ﴿٢٨﴾
And We have not sent you except comprehensively to mankind as a bringer of good tidings and a warner. But most of the people do not know.
The message was for all peoples, including Africa.
Sahih al-Bukhari 3877
Sahih... مات اليوم رجل صالح فقوموا فصلوا على أخيكم أصحمة ...
"A righteous man has died today, so stand and pray over your brother Ashama."
The Najashi of Abyssinia died a Muslim.
Where the ruling is recorded
- Sirat Ibn Hisham, Account of the migration to Abyssinia. The first emigrants and the Najashi's protection.
- Futuh al-Buldan (al-Baladhuri), Chapters on the conquest of Egypt and of North Africa. Early account of the campaigns of Amr and Uqba.
- Rihla (Ibn Battuta), Account of his journey to the East African coast. Describes the Muslim towns of Mogadishu and Kilwa in the 1330s.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.