The North African countries of Morocco, Algeria, Tunisia and Libya are Muslim countries. Their rulers are also religions heads. The Sultan of Morocco is addressd as the Commander of the Faithful.
These countries first came under the influence of Islam during the Arab invasions in the 7th and 8th centuries A.D.
Islam In Egypt And Sudan

Egypt is not only a Muslim country but also claims to be the center of the Arab World. It has joined with Syria to become the United Arab Replublic. The Muslim Arabs conquered it in the 642. Cairo was founded in the 10th century as the capital of the Fatimid family of rulers.
The Republic of the Sudan, to the south of Egypt, produced many religions during the last century. In the 1881 Sheikh Muhammad Ahmed proclaimed himself the saviour of his country and threw off the Egyptian rule. He wanted not only to free the Sudan from foreign rule but also to unite the Muslim world and to wage a Holy War (Jihad) against all pagans. At first he was successful.
The first Egyptian army which was went out against him was destroyed. He advanced into Abyssinia but there he was defeated. He died in 1885 and was succeeded by Khalifa. Khalifa was finally defeated by General Gordon in 1898.
ZANZIBAR
For more than a thousand years the coast of East Africa, from the Red Sea to Cape Delgado, was ruled by Muslim. They were Arab slave traders who came from Arabia and from the Persan Gulf. They built cities such as Malindi, Kilwa (which is said to have had 300 Mosques), Mombasa and Zanzibar. Although these areas were never united under one ruler, they were known as the Zenj Empire. (The Zenj were the mixed Afro-Asian poeple now called the Swahili). In the 15th century the Portuguese conquered the Zenj Empire but only ruled it all for about a hundred years. Arabs from Oman regained control of the east coast cities.
In 1832, Imam Said of Muscat (the capital of Oman) united all the Arab settlements and made Zanzibar his African headquarters. Being on an Island with a good harbour it was well situated for the control and development of the slave trade.
When the movement began to stop this trade the British Navy patrolled the East African ports. In 1873, Sir John Kirk, who had for long been British Consul in Zanzibar, persuade Bargash ibn Said, the Sultan of Zanzibar to close the slave market on the Island for ever.
Later, the Zanzibar territories on the mainland were split up and became protectorates of European states. Zanzibar and the island, Pemba, became a British protectorate in 1890. Since that time, they developed slowly and peacefully. Their constitution was gradually changed until on December 10th, 1963 they became an independent state, two days before their mainland neighbour, Kenya. This was done in order to show that Zanzibar was a truly independent Muslim sultanate and not merely a very small part of Kenya.
Nonetheless, it was clear that it would be very difficult for two small island, less than 30 miles from Kenya and smaller in population than Lagos, to pay all the cost of an independent government.
Moreover, there had been much discortent among the African majority who were related to many of the peoples on the mainland. After the loss of their mainland territories and their trade in slaves in the clove and coconut farms and kept the government of the two island firmly in their own hands. So whilst the 45,000 Arabs had nearly all been very wealthy, most of the 250,000 Africans had been very poor. When the two island had been independent for only on month, there was a rebellion; the Arab government was everthrow and on January 13th 1964, Sultan Sayyid Jamshid bin Abdullah was forced to leave the country.

We may conclude this story by saying that in Africa as a whole, Islamhas been very successful in making converts. For, like other universal religions, it has freed African men and women from their fear of many little tribal gods. In place of such local gods, separating one tribe from another, Islam says “There is no god but Allahand Muhammed is His Prophet”. It is a simple creed that can be understood by all. It has been spread through Africa by wandering Muslim traders and teachers. They had no need to build a Mosque; each carried his prayer mat with him. The simple practice of daily prayer in publuc impressed the pagan villagers. Islam was clearly better than their daily way of life. The present backwradness of Islamic countries may be due partly to the fact that Islam preached the brotherhood and equality of man some claime’s that Islam denied freedom to women and slaves. Read here 15 Common Misconceptions about Muslims…..