Mohamed Mustafa Ma al-'Aynayn (c. 1830–31 in Oualata, present-day Mauritania – 1910 in Tiznit, Morocco; complete name Mohamad Mustafa ben Mohamad Fadel Maa al-'Aynayn ash-Shanguiti Arabic: محمد مصطفى بن محمد فاضل ماء العينين الشنكيطي) was a Saharan Moorish religious and political leader who fought French and Spanish colonization in North Africa. He was the son of Mohammed Fadil Mamin (founder of the Fadiliyya, a Qadiriyya Sufi brotherhood), and the elder brother of shaykh Saad Bouh, a prominent marabout (religious leader) in Mauritania.
In 1859, Ma al-'Aynayn—a nickname he received as a child, meaning "water of the two eyes" in Arabic, in reference to the Qadiriya Sheikh Sidi Ahmed El Bekkay who immigrated to Oualata a few centuries earlier—settled in the oasis of Tindouf in present-day Algeria. The son of a famous Marabout, he quickly became known as a great scholar. His nomadic encampment attracted many students of Islamic law. In 1887 he was appointed as Caid of Tindouf by the sultan of Morocco Hassan I.
In 1898, Ma al-'Aynayn began building a Ribat in Smara, in the Spanish Sahara (present-day Western Sahara). His goal in creating the Ribat, which was previously just a water center for travelers, was to launch attacks on European colonial forces and particularly the French. The Moroccan sultan Abdelaziz assisted him in building the Ribat, as he sent craftsmen, materials, financing and arms, and also appointed him Caid. In 1902, he moved there creating among other things an Islamic library.