Sidi al-Ayachi, also el-Ayachi or al-Ayashi (-1641), was a Moroccan marabout, warlord, and jihadist. The Sultan of Morocco, Mulay Zidan al-Nasir, had made him governor (qā′id) of Azmūr, but in 1627 he decided to secede and create his own state.
Since the death of Mulay al-Mansur in 1603, Morocco had progressively fallen into a state of anarchy, with the Sultan losing authority. With Morocco in a state of civil war, the Spanish seized the opportunity to capture the cities of Larache in 1610 and then al-Ma'mura in 1614. The Sultan's seeming inability to defend the country, infuriated Sidi al-Ayachi, and he began a counter-offensive against Spain, privateering against its shipping, and obtaining the help of the Moriscos and the English. He managed to re-capture al-Mamura, albeit temporarily, and extended his power as far as Taza.
In April 1627, Sidi al-Ayachi revolted against the Sultan and attacked the harbour of Salé, which he captured and transformed into his own principality, the Republic of Bou Regreg, becoming its independent governor. The English diplomat John Harrison negotiated a treaty with Sidi al-Ayachi in May 1627, a month later. The Dutch also strong supported Sidi al-Ayachi, and supplied him with arms.
It was not until Sutan Mohammed esh Sheikh es Seghir came to the throne in 1636, that real efforts were made to restore the lands of Sidi al-Ayachi to the throne. Sidi al-Ayachi was killed in battle in 1641.