The Sanhaja (Berber: Aẓnag, pl. Iẓnagen, and also Aẓnaj, pl. Iẓnajen; Arabic: صنهاجة, Ṣanhājah) were once one of the largest Berber tribal confederations, along with the Zanata and Masmuda confederations. Many tribes in Morocco and Mauritania bore and still carry this ethnonym, especially in its Berber form. Other names for the population include Zenaga, Veledi Sanhája, Znaga, Sanhája, Sanhâdja and Senhaja.
After the arrival of Islam, the Sanhâdja spread out to the borders of the Sudan as far as the Senegal River and the Niger. From the 9th century, Sanhaja tribes were established in the Middle Atlas range, in the Rif Mountains and on the Atlantic coast of Morocco. A part of the Sanhaja, such as the Kutâma, settled in central/eastern Algeria and northern Niger. They played an important part in the rise of the Fatimids. The Sanhaja dynasties of the Zirids and Hammâdids controlled Ifriqiya until the 12th century.
In the mid-11th century, a group of Sanhadja chieftains returning from the Hâjj (big pilgrimage) invited the theologian Ibn Yâssin to preach among their tribes. Ibn Yasin united the tribes in the alliance of the Almoravids in the middle of the 11th century. This confederacy subsequently established Morocco, and conquered western Algeria and Al-Andalus (part of present-day Spain).
The Znaga or Zenaga tribes would remain in roles as either exploited semi-sedentary agriculturalists and fishermen (Znaga tribes), or, higher up on the social ladder, as religious (Marabout or Zawiya) tribes. Though often Arabized in culture and language, they are believed to be descended from the Zenata or Sanhaja Berber population present in the area before the arrival of the Arab Maqil tribes in the 12th century, which was finally subjected to domination by Arab-descended warrior castes in the 17th century Char Bouba war according to Mercer, the word "znaga" is thought to be a distortion of "Zeneta and Sanhaja".
The descendants of the Sanhaja are still found today in the Middle Atlas mountains and eastern Morocco.