One of its generals was Ali bin Abdallah al-Riffi, a native of Temsamane, who became governor of Tangier, Asilah and Tetouan.
In the late 17th century, the famous Moroccan sultan Moulay Ismail created a new elite army, consisting of over 100,000 black African slaves.
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.
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 (and neighbouring cities like Tetouan and Ksar el-Kebir) became virtually autonomous under Riffian governors.
Even though these Riffians had participated in several unsuccessful campaigns to capture English Tangiers in 1680s, from the late 1690s onwards the Hamamis developed strong economic and diplomatic ties to the British territory of Gibraltar.