The ancient tribes of Mauritania were Berber and Niger-Congo people. The Bafours were primarily agricultural, and among the first Saharan people to abandon their historically nomadic lifestyle. With the gradual desiccation of the Sahara, they headed south Many of the Berber tribes claimed Yemeni (and sometimes other Arab) origins. There is little evidence to support such claims, but a 2000 DNA study of Yemeni people suggested there might be some ancient connection between the peoples.
Other peoples also migrated south past the Sahara to West Africa. In 1076 the Almoravids conquered the large area of the ancient Ghana Empire. The Char Bouba war (1644–74) was the unsuccessful final effort of the peoples to repel the Yemeni Maqil Arab invaders. The invaders were led by the Beni Hassan tribe. The descendants of the Beni Hassan warriors became the upper stratum of Moorish society. Hassaniya, a bedouin Arabic dialect that derives its name from the Beni Hassan, became the dominant language among the largely nomadic population.
Source : Wikipedia