By the beginning of the 1st millennium A.D. Sanhaja Berbers had migrated into Mauritania, pushing the black African inhabitants (especially the Soninké) southward toward the Senegal River. The Hodh region, which became desert only in the 11th cent., was the center of the ancient empire of Ghana (700–1200), whose capital, Kumbi-Saleh, located near the present-day border with Mali, has been unearthed by archaeologists. Until the 13th cent., Oualata, Awdaghost, and Kumbi-Saleh, all in SE Mauritania, were major centers along the trans-Saharan caravan routes linking Morocco with the region along the upper Niger River.
In the 11th cent. the Almoravid movement was founded among the Muslim Berbers of Mauritania. In the 14th and 15th cent., SE Mauritania was part of the empire of Mali, centered along the upper Niger. By this time the Sahara had encroached on much of Mauritania, consequently limiting agriculture and reducing the population. In the 1440s, Portuguese navigators explored the Mauritanian coast and established a fishing base on Arguin Island, located near the present-day boundary with Western Sahara.
From the 17th cent., Dutch, British, and French traders were active along the S Mauritanian coast; they were primarily interested in the gum arabic gathered near the Senegal River. Under Louis Faidherbe, governor of Senegal (1854–61; 1863–65), France gained control of S Mauritania. The region was declared a protectorate in 1903, but parts of the north were not pacified until the 1930s.
Until 1920, when it became a separate colony in French West Africa, Mauritania was administered as part of Senegal. Saint-Louis, in Senegal, continued to be Mauritania's administrative center until 1957, when it was replaced by Nouakchott. The French ruled through existing political authorities and did little to develop the country's economy or to increase educational opportunities for the population. National political activity began only after World War II. In 1958, Mauritania became an autonomous republic within the French Community.
On Nov. 28, 1960, Mauritania became fully independent. Its leader at independence was Makhtar Ould Daddah, who in 1961 formed the Mauritanian People's Party (which in 1965 became the country's only legal party) and was the leading force in establishing a new constitution. Ould Daddah was elected president in 1961; the same year Mauritania became a member of the United Nations.
The 1960s were marked by tensions between the black Africans of the south and the Arabs and Berbers of central and N Mauritania, some of whom sought to join Mauritania with Morocco. By the early 1970s the main conflicts in the country were over economic and ideological rather than ethnic matters, as dissident workers and students protested what they considered an unfair wage structure and an undue concentration of power in Ould Daddah's hands. The long-term drought in the semiarid Sahel region in the south, which lasted from the late 1960s into the 1980s, caused the death of about 80% of the country's livestock, as well as extremely poor harvests in the Senegal River region.
Ould Daddah attempted to act as a bridge between N Africa and black Africa and in the early 1970s was on good terms with Libya, Algeria, Tunisia, and Morocco as well as with the black African nations of Senegal and Liberia. In 1973, Mauritania became a member of the Arab League. In the same year the country began to loosen its ties with France by withdrawing from the Franc Zone and establishing its own currency. In 1976, when Spain relinquished control of Spanish Sahara, the territory became Western Sahara and was partitioned between Morocco and Mauritania. This move left Mauritania (as well as Morocco) in conflict with the Polisario Front, a group of nationalist guerrillas fighting for independence for Western Sahara.
Ould Daddah's regime was overthrown in 1978, and Lt. Col. Mustapha Ould Mohamad Salek assumed power, promising to end involvement in the war. Salek's proposed Arabization of the country's educational system made him many enemies in the African community. He resigned and was succeeded by Lt. Col. Mohamed Mahmoud Ould Louly in 1979. In that year, Mauritania, under pressure from the Polisario Front, renounced all claims to Western Sahara. In 1980, Ould Louly was overthrown and replaced by Prime Minister Lt. Col. Mohamed Khouna Ould Heydalla. In 1981, Mauritania severed diplomatic relations with Morocco after it appeared Morocco had engineered a coup attempt against Heydalla. In 1984, Lt. Col. Maaouiya Ould Sidi Ahmed Taya overthrew Heydalla's regime. Taya restored relations with Morocco in 1985.
In 1989, racial tensions between blacks and Moors reached new heights as 40,000 black Senegalese workers were driven out of the country. Rioting resulted, tens of thousands of black Mauritanians were forced from their land by the military (many of whom fled to Senegal), and Mauritania broke off diplomatic relations with Senegal. In 1991 a new constitution providing for multiparty rule was approved by referendum. President Taya was reelected in 1992 and 1997, amid allegations of fraud. In 1993 the United States stopped development aid to Mauritania in protest against the country's oppression of its black citizens and its support of Iraq during the Persian Gulf War; the government subsequently moved toward a pro-Western position.
Taya survived a coup attempt in June, 2003. In the Nov., 2003, presidential elections he received 66.7% of the vote; his nearest challenger, former president Heydalla, almost 19%. Despite new voting safeguards designed to prevent vote-rigging, there were again accusations of fraud. Heydalla was arrested after the election on charges of plotting a coup, which he denied. He received a suspended five-year sentence in December, and as a result of the sentence he lost his political and civil rights for five years. In Aug. and Sept., 2004, Mauritanian officials said they had foiled two more coup plots. At the same time, locusts ravaged a large portion of the nation's agricultural land, leading to concerns of a possible food crisis.
In Aug., 2005, while President Taya was abroad, the long-time national security chief, Col. Ely Ould Mohamed Vall led a coup that replaced Taya with a 17-member military council headed by Vall. The coup was quickly denounced by the African Union, United States, and others, but after the council promised to hold democratic legislative elections within two years the objections ended. Mauritanians generally greeted the Taya's overthrow with celebration, and opposition groups with qualified approval.
In 2006 voters approved a new constitution limiting a president to two five-year terms in office. In the legislative elections (Nov.–Dec., 2006) a coalition of former opposition parties won the largest bloc of seats, followed by independents, but no group won a majority. Senatorial elections were held in Jan., 2007, and in March Sidi Ould Cheikh Abdallahi, a former government minister who ran as an independent but was supported by former government parties and was regarded as the military's candidate, was elected president after a runoff. In 2008, however, increasing food prices and concerns over the government's overtures to Islamists led to government instability beginning in May and tensions between the president and parliament. In August, after the president dismissed several military and security leaders, one of them, Gen. Mohamed Ould Abdel Aziz, overthrew the president and replaced the presidency with a military-dominated council; a new cabinet was appointed in September. Mauritania saw an increase in Islamic militant attacks in the months following the coup, and fighting between Islamist and government forces continued sporadically into subsequent years, at times spilling across the border into Mali.
Aziz resigned from the military and the government in Apr., 2009, in order to run for president; Senate President Ba Mamadou Mbare became interim head of state. In June, 2009, a settlement negotiated as a prelude to new elections led to the formation of a power-sharing government that included military- and opposition-appointed members. As part of the agreement Abdallahi appointed the interim government and then officially resigned as president.
The presidential election in July, 2009, resulted in a victory for Aziz, with more than 52% of the vote, but the main opposition candidates rejected the results. The president was injured in a shooting in Oct., 2012, reportedly accidentally, though some reports suggested it might have been an assassination attempt. The president's party, Union for the Republic, won a majority of the seats in the legislature in the Nov.–Dec., 2013, elections, with its allies winning additional seats, but all but one of the parties in the 11-party opposition alliance boycotted the vote.