Increasingly disturbed by Western penetration of the area, which he viewed both as an intrusion by hostile foreign powers and as a Christian assault on Islam, he began agitating for resistance. Local Saharan tribes performed ghazi raids against the foreign forces, but French troops drew ever closer, conquering one local ruler after another.

In 1904, Ma al-’Aynayn proclaimed a holy war, or jihad, against the colonizers. He proclaimed that the trab al-beidan (a desert area that includes today’s Mauritania, southern Morocco, Western Sahara and large swaths of northern Mali and southern-western Algeria) was under the Sultan’s rule[citation needed]. The Sultan of Morocco did not have direct control over Ma al-’Aynayn’s forces but this display of effective cooperation helped assemble a large coalition of tribes to fight the colonizers. Ma al-’Aynayn set about acquiring firearms and other materials both through channels in Morocco and through direct negotiations with rival European powers such as Germany[citation needed], and quickly built up a sizable fighting force. A member of his Gudfiyya brotherhood in 1905 may have assassinated Xavier Coppolani, who was leading the French conquest of Mauritania, thereby delaying the conquest of the emirate of Adrar for a few years.

In 1906 the Sultan Abdelaziz ratified the Algeciras Conference, granting colonial powers substantial concessions over Morocco, Ma al-’Aynayn’s deemed this a betrayal, and supported in 1907 the Sultan’s brother and rival Abdelhafid (at the time opposed to the French). The flow of arms from Morocco dwindled as a result. The French forces under then-colonel Gouraud pushed forward in the French Sudan, and Ma al-’Aynayn was forced to retreated to Tiznit (Morocco) in 1908-1909 determined to fight along Abdelhafid in dethroning his brother, which they succeeded in doing. Around this time, he proclaimed himself Mahdi in Tiznit.

In 1910, anarchy spread through Morocco, as the new Sultan grew ever weaker under European pressures. Ma al-’Aynayn, concerned that Morocco would fall in European hands, decided to extend Jihad north of Tiznit at the head of an army of 6,000 men to overthrow the new Sultan Abdelhafid. He was defeated by French General Moinier, on June 23, 1910. He would die several months later at Tiznit, on October 23 of the same year.

NOTE! Nation data for this war may be inconlusive or incomplete. In most cases it reflects which nations were involved with troops in this war, but in some it may instead reflect the contested territory.