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 which 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).