From the 3rd to 7th centuries, the migration of Berber tribes from North Africa displaced the Bafours, the original inhabitants of present-day Mauritania and the ancestors of the Soninke. Continued Arab-Berber migration drove indigenous black Africans south to the Senegal River or enslaved them. By 1076, Islamic warrior monks (Almoravid or Al Murabitun) completed the conquest of southern Mauritania, defeating the ancient Ghana empire. Over the next 500 years, Arabs overcame fierce Berber resistance to dominate Mauritania. The Mauritanian Thirty-Year War (1644-74) was the unsuccessful final Berber effort to repel the Maqil Arab invaders led by the Beni Hassan tribe. The descendants of Beni Hassan warriors became the upper stratum of Moorish society. Berbers retained influence by producing the majority of the region's Marabouts -- those who preserve and teach Islamic tradition. Hassaniya, a mainly oral, Berber-influenced Arabic dialect that derives its name from the Beni Hassan tribe, became the dominant language among the largely nomadic population. Aristocrat and servant castes developed, yielding "white" (aristocracy) and "black" Moors (the enslaved indigenous class).
French colonization at the beginning of the 20th century brought legal prohibitions against slavery and an end to interclan warfare. During the colonial period, the population remained nomadic, but sedentary black Africans, whose ancestors had been expelled centuries earlier by the Moors, began to trickle back into southern Mauritania. As the country gained independence in 1960, the capital city Nouakchott was founded at the site of a small colonial village, the Ksar, and 90% of the population was still nomadic. With independence, larger numbers of ethnic Sub-Saharan Africans (Haalpulaar, Soninke, and Wolof) entered Mauritania, moving into the area north of the Senegal River. Educated in French language and customs, many of these recent arrivals became clerks, soldiers, and administrators in the new state.
Moors reacted to this change by increasing pressure to Arabicize many aspects of Mauritanian life, such as law and language. A schism developed between those who consider Mauritania to be an Arab country (mainly Moors) and those who seek a dominant role for the Sub-Saharan peoples. The discord between these two conflicting visions of Mauritanian society was evident during intercommunal violence that broke out in April 1989 (the "1989 Events"), but has since subsided. The tension between these two visions remains a feature of the political dialogue. A significant number from both groups, however, seek a more diverse, pluralistic society.
Between 2005 and 2011, Al-Qaeda in the Islamic Maghreb (AQIM) launched a series of attacks killing American and foreign tourists and aid workers, attacking diplomatic and government facilities, and ambushing Mauritanian soldiers and gendarmes. Although Mauritania has not seen an attack since 2011, AQIM and similar groups remain active in the Sahel region.