The Maghariba (Arabic: المغاربة al-Maghāribah, meaning "Westerners") were a regiment in the regular army of the Abbasid Caliphate. The unit was formed in the early ninth century A.D. and consisted of soldiers who were of North African origin. During their history, the Maghariba participated in several military campaigns and played a significant role in the politics of the central government.
The origin and composition of the Maghariba have been subject to debate. Historians have variously described the Maghariba as Berbers from North Africa, black slaves from East Africa, and Arab tribesmen from Egypt, with the last being the most widely accepted theory. According to the Muslim historian al-Mas'udi, the regiment was created by Caliph al-Mu'tasim (r. 833–842), who recruited troops from the Hawf districts of Egypt; this likely occurred before al-Mu'tasim's caliphate, when he and al-Afshin were serving in Egypt on behalf of the caliph al-Ma'mun (r. 813–833).
After the succession of al-Mu'tasim to the caliphate in 833, the Maghariba formed a contingent of the his new army, along with other units such as the Turks, the Faraghina, the Ushrusaniyya, and the shakiriyya. Together with the rest of the army, they were granted their own section in al-Mu'tasim's new capital city of Samarra; their allotments were along the Gulf Street (shāri' al-khalīj) adjacent to the bank of the Tigris, and the Azlakh quarter was known as a Maghribi neighborhood.
The Maghariba appear to have served as infantry, and they were a mixture of free men and slaves. They were likely fewer in number than the Turks, and they were certainly of inferior status. Their pay also appears to have been lower; on the accession of al-Mutawakkil (r. 847–861), the new caliph ordered that the Maghariba be given lower allotments than the rest of the army, and in 870 al-Muhtadi (r. 869–870) arranged for the Maghariba to be paid one dirham a day, while the Turks and other units received two.