Most populations in North Africa are of Berber heritage, including those inhabiting Morocco, Algeria, Tunisia, Libya, Western Sahara, and Mauritania. The widespread language shift from Berber to Arabic happened, at least partially, due to the privileged status that the Arabic language has generally been given in the states of North Africa, from the Arab conquest in 652 up until the European conquest in the twentieth century, as well as the migration of the Banu Hilal and Banu Sulaym tribes to North Africa.
Medieval Arabic sources frequently refer to North Africa (excluding Egypt) as Bilad Al Barbar or 'Land of the Berbers' (Arabic: بلادالبربر) prior to the Muslim conquest of the Maghreb. This designation may have given rise to the term Barbary Coast which was used by Europeans until the 19th century to refer to coastal Northwest Africa. But the cultural impact of Islam was big as it was the only boost for the spread of the Arabic language.
Since the populations were partially affiliated with the Arab Muslim culture, North Africa was starting to be referred to by the Arabic speakers as Al-Maġrib (meaning "The West") since it was considered as the western part of the known world. For historical references, medieval Arab and Muslim historians and geographers used to refer to Morocco as Al-Maghrib al Aqşá ("The Farthest West"), disambiguating it from neighboring historical regions called Al-Maghrib al Awsat ("The Middle West", Algeria) and Al-Maghrib al Adna ("The Nearest West", Tunisia).
Even though many of these cities have often been linguistically Arabized (like Fes or Marrakesh), from a historic point of view it is accepted that the core population of North Africa is Berber.[according to whom?] More than rural areas, the cities were a melting pot of different ethnicities, so the city dwellers are more likely to have non-pure Berber ancestry.
By tracing the history of certain Maghrebian areas, historians are able to make assertions about its inhabitants. For instance, even though Casablanca (Berber name: Anfa) and Rabat were both built and originally settled by Berbers, we know that the area's original inhabitants were ousted by the Almohads and subsequently resettled with nomadic Banu Hilal Arabs. Other, traditionally Berber, cities like Tangiers, Meknes and Marrakesh have never had such a drastic repopulation, so that we can assume that its inhabitants today are of Berber stock. Although these cities have for centuries now been linguistically Arabized, their culture and identity often have not been through that process. The cities of Tangiers, Tetouan, Meknes and Marrakesh still have a strong regional Berber aspect to them and their inhabitants do not necessarily consider themselves to be ethnically Arab, even though their language might be today's Moroccan-Arabic.
According to Berber nationalists, although a North African may only speak Maghrebi Arabic as opposed to a Berber language, this person is still essentially Berber since he or she is ancestrally of Berber origin.
It is a response from Berber activists to those Algerians and Moroccans who self-identify as "Arab" because of their Arabic tongue. North Africa was gradually Arabized with the spread of Islam in the 7th century AD, when the liturgical language Arabic was first brought to the Maghreb. However, the identity of northwestern Africa remained Berber for a long time thereafter. Additionally, even though the process of Arabization began with these early invasions, many large parts of North Africa were only recently Arabized like the Aurès (Awras) mountains in the 19th and 20th centuries. Although, the fertile plains of North Africa seem to have been (at least partly) Arabized in the 11th century with the emigration of the Banu Hilal tribes from Arabia. The mass education and promotion of Arabic language and culture through schools and mass media, during the 20th century, by the Arabist governments of North Africa, is regarded as the strongest Arabization process in North Africa ever.
Various population genetic studies along with historians such as Gabriel Camps and Charles-André Julien lend support to the idea that the bulk of the gene pool of modern maghrebis, irrespective of linguistic group, is derived from the Berber populations of the pre-Islamic period.