Remnants of Stone Age cultures have been found in northern Mauritania. Berber nomads moved into the area in the 1st millennium ad and subjugated the indigenous black population. The newcomers belonged to the Sanhaja Confederation that long dominated trade between the northern parts of Africa and the kingdom of Ghana, the capital of which, Kumbi Saleh (Koumbi Saleh), was in southeastern Mauritania. Under Almoravid leadership, the Sanhaja razed Kumbi Saleh in 1076, although Ghana survived until the early 13th century. The Berbers, in turn, were conquered by Arabs in the 16th century. The descendants of the Arabs became the upper stratum of Mauritanian society, and Arabic gradually displaced Berber dialects as the language of the country. French forces, moving up the Senegal River, made the area a French protectorate by 1905 and a colony in 1920. In 1946 Mauritania became an overseas territory of the French Union. Under French occupation, slavery was legally abolished.
The Islamic Republic of Mauritania was proclaimed on November 28, 1958, under the constitution of the Fifth French Republic, and on November 28, 1960, it became fully independent. It joined the United Nations in 1961. That same year Moktar Ould Daddah was elected its first president; he was reelected in 1966, 1971, and 1976.
Mauritania was severely affected by a drought in the late 1960s and early 1970s. Nevertheless, its economy expanded as newly discovered iron and copper deposits were exploited. In 1976 it annexed the southern third of adjacent Spanish Sahara, which at that time was ceded by Spain; Morocco received the rest of the territory. A Saharan nationalist movement, the Polisario Front, seeking to make the Western Sahara an independent nation, weakened Mauritania with guerrilla warfare. In July 1978, President Daddah was ousted in a coup led by Lieutenant Colonel Mustafa Ould Salek. After he was replaced by another army officer, Mohamed Ould Louly, Mauritania agreed, in August 1979, to withdraw from the Western Sahara.
Another change of leadership occurred in 1980, when the prime minister, Mohamed Ould Haidalla, assumed the presidency. He subjected the nation to strict enforcement of Islamic law. Haidalla survived a coup in 1981 but was deposed by his chief of staff, Colonel Maaouya Ould Sidi Ahmed Taya, in 1984. Tensions with Senegal in 1989 resulted in the repatriation of 100,000 Mauritanian nationals from Senegal and the repatriation or expulsion of 125,000 Senegalese nationals from Mauritania. Faced with rising domestic pressures and international criticism of his human rights record, Taya implemented a new constitution and legalized opposition parties in 1991. He was chosen executive president in a disputed election in January 1992 and was reelected in December 1997.