Jaysh al-Rifi was the name of an influential Moroccan army corps in the 17th and 18th centuries. The army was formed by Moulay Ismail out of Berber tribesmen from the eastern Rif. Their rise coincided with the formation of the Black Guard, also by Moulay Ismail. They came to play an important role in the 17th century Moroccan wars against Spanish colonization. Cities like Tangier, Ksar el-Kebir, Mehdya, Asilah were reconquered by the Jaysh al-Rifi. One of its generals was Ahmad al-Rifi, a native of Temsamane, who became governor of Tangier, Asilah and Tetouan. His descendants, the Hamami al-Rifi family, would govern these towns, and most of the Gharb, with a large degree of autonomy until 1912.
Background
The Moroccan ruling Alaouite dynasty had no strong tribal base, as their legitimacy was based on them being descendants of the Prophet Muhammad, not on a particular ethnic or tribal nationalism. This meant that they had to incorporate a diverse range of tribes across Morocco, given that their original base was not particularly strong. In the earliest years of Alaouite rule the state relied on Arab bedouin tribes from Morocco's deep south, as well as Arabs and Zenata recruited from the Atlantic plains. Berber tribes from the Sous as well as those from the southern river valleys were also incorporated. These different components were not always reliable though, often rebelling and showing no particular allegiance to the state. In the late 17th century, the famous Moroccan sultan Moulay Ismail created a new elite army, consisting of over 100,000 black African slaves. This Black Guard would come to dominate the Alaouite military and overall politics. Besides this strong standing army, the sultan made use of the jaysh. These consisted of soldiery recruited from tribal groups. These jaysh' were decentralized, and leadership was often tribal in nature. In the south en center of the country, these jaysh' were formed from rural Arabs, as well as Berber tribes of the plains of the Middle Atlas and the High Atlas. In the north, Berber Riffian jaysh came to dominate, with Riffian armies used against the Spanish-governed cities on the Moroccan coast. Riffian jaysh' came to be stationed across northern Morocco, from Tangiers to the Moulouya river. To strengthen his hold on the north-west, Ismail had appointed a general of the Jaysh to the position of governor of Tangier and its outskirts.
Pashas of Tangiers
With the death of Moulay Ismail, the BlackArmy generals became the effective rulers of the state. Unlike Ismail, the new sultans were weak and incompetent, with different groups supporting different princes. In the north, the Jaysh al-Rifi generals consolidated their power and successfully fought an attempt by the Black Army to weaken their hold on Tangiers, which led to a situation where Tangiers became virtually autonomous under Riffian governors. Even though these Riffians had led the struggle against British Tangiers in 1680s, from the late 1690s onwards the Hamamis developed strong economic and diplomatic ties to British Gibraltar. In the 1740s, the family broke out in rebellion against the sultan, but they were decisively beaten in battle. By that time the family had such a strong power base in the north-west, that the Makhzen was forced to appoint another member of the family to the position of governor. The last of these Riffian gouvernors of Tangier, a descendant of Ahmad al-Rifi, was deposed in 1912.