The family's rise to power took place in the context of early-to-mid-17th century Morocco, when the power of the Saadian sultans of Marrakesh was in serious decline and multiple regional factions fought for control of the country. Among the most powerful of these factions were the Dala'iyya (also spelled Dila'iyya or Dilaites), a federation of Amazigh (Berbers) in the Middle Atlas who increasingly dominated central Morocco at this time, reaching the peak of their power in the 1640s. Another, was 'Ali Abu Hassun al-Semlali (or Abu Hassun), who had become leader of the Sous valley since 1614. When Abu Hassun extended his control to the Tafilalt region in 1631, the Dala'iyya in turn sent forces to enforce their own influence in the area. The local inhabitants chose as their leader the 'Alawi family head, Muhammad al-Sharif – known as Mawlay Ali al-Sharif, Mawlay al-Sharif, or Muhammad I – recognizing him as emir. Mawlay al-Sharif led an attack against Abu Hassun's garrison at Tabu'samt in 1635 or 1636 (1045 AH) but failed to expel them. Abu Hassun forced him to go into exile to the Sous valley, but also treated him well; among other things, Abu Hassun gifted him a slave concubine who later gave birth to one of his sons, Mawlay Isma'il.