The Sanhaja (, or ; , pl. , and , pl. ) were a large Berber tribal confederation, along with the Zanata and Masmuda confederations. Many tribes in Algeria, Libya, Mali, Mauritania, Morocco, Niger, Senegal, Tunisia and Western Sahara bore and still carry this ethnonym, especially in its Berber form.
Other names include Zenaga, Znaga, Sanhája, Sanhâdja and Senhaja.
Ibn Khaldun and others defined the Sanhaja as a grouping made up of three separate confederations, not as a single confederation. The distinction is usually made with a diacritical point placed above or below that is present in the Arabic text and often lost in English.
Arab historians often attributed Himyarite origins to Berber tribes such as the Sanhaja and Kutama, who likely adopted those origins for political legitimacy. The historian al-Idrisi presented one example of the Himyarite myth:
After the arrival of Islam, the Sanhaja spread to the borders of the Sudan region as far as the Senegal and Niger rivers.
The Sanhaja were a large part of the Berber population. From the 9th century, tribes were established in the Middle Atlas, the Rif Mountains and on the Atlantic coast of Morocco. Many of the Sanhaja, including the Kutama, settled in central and eastern Algeria (including Kabylia, Sétif, Algiers and M'sila) and northern Niger. The Kutama Fatimid Caliphate conquered all of North Africa and some of the Middle East. The Sanhaja Zirid and Hammadid dynasties controlled Ifriqiya until the 12th century, and ruled over all of the Maghreb.
In the mid-11th century, a group of Sanhaja chieftains returning from Hajj invited theologian ibn Yasin to preach among them. Ibn Yasin then united the tribes under the Almoravid dynasty, which established Morocco and conquered western Algeria and al-Andalus.
The Sanhaja remained either exploited semi-sedentary agriculturalists and fishermen, or religious (marabout or zawiya) tribes. Though often Arabized in culture and language, they descended from the population present before the arrival of the Arab Maqil tribes in the 12th century. They were subjugated by Arab-descended warrior castes in the 17th-century Char Bouba war.
According to Mercer, the words Zenaga or Znaga (from the Berber root áºÂnag or áºÂnaj, giving the noun AáºÂnag or AáºÂnaj with the additional masculine singular prefix a-, or TaáºÂnagt or TaáºÂnajt with the additional feminine singular circumfix ta--t, or IáºÂnagen or IáºÂnajen with the additional masculine plural circumfix i--en, or TiáºÂnagen or TiáºÂnajen with the additional feminine plural circumfix ti--en) are thought to be a romanized distortion of Zenata and Sanhaja from Arabic.
The descendants of the Sanhaja and their languages are still found in the Middle Atlas mountains, Sous, Western Sahara, northern and eastern Morocco, western Algeria, and Kabylia.
The Zenaga are a small population, believed to be of Gudala origin, that inhabit southwestern Mauritania and parts of northern Senegal.