Muhammad ibn Abd al-Karim al-Khattabi was the founder of the Republic of the Rif and the principal Berber anti-colonial commander of the early twentieth century. Born in 1882 in Ajdir near Al Hoceima in the central Rif, he was educated in Spanish at Melilla and in Arabic and Islamic law at the Qarawiyyin in Fez before returning to the Rif as a teacher, journalist, and judge under the Spanish protectorate administration.
His political turn followed a period of imprisonment by the Spanish authorities in 1916–1917 over his anti-German positions during the First World War. After his father's death in 1920 he assumed leadership of the Beni Ouriaghel and the surrounding tribes, and on 22 July 1921 he destroyed a Spanish colonial force of some twenty thousand men at the Battle of Annual — one of the heaviest defeats inflicted on a European colonial army in the early twentieth century.
In September 1921 he was acclaimed Amir, and in February 1923 the Republic of the Rif was formally proclaimed at Ajdir with a constitution, a flag, a postal service, and a national bank. The republic survived for five years against successive Spanish offensives before falling to a combined Franco-Spanish campaign in 1925–1926 that committed nearly five hundred thousand troops and used aerial chemical weapons on a large scale.
Abd al-Karim surrendered to French forces on 27 May 1926 and was exiled to Réunion until 1947, when he escaped en route to France during a transfer and reached Cairo. He lived there until his death in 1963, presiding over the Liberation Committee of the Arab Maghreb and corresponding with anti-colonial leaders across Asia and Africa. His military doctrines, derived from Rifian customary warfare, were studied by Mao Zedong, Ho Chi Minh, and Che Guevara as a foundational example of guerrilla resistance.