Anarchism in Morocco has its roots in the federalism practiced by Amazigh communities in pre-colonial Morocco. During the Spanish Civil War, Moroccan nationalists formed connections with Spanish anarchists in an attempt to ignite a war of national liberation against Spanish colonialism, but this effort was not successful. Despite the brief establishment of an anarchist movement in post-war Morocco, the movement was suppressed by the newly independent government, before finally reemerging in the 21st century.
Morocco was largely stateless until the arrival of the Phoenicians in the 8th century BCE, which heralded centuries of foreign rule. An independent Amazigh kingdom was established in the 3rd century BCE, but was eventually incorporated into the Roman Empire. The Muslim conquest of the Maghreb took place throughout the later 7th century CE, bringing Morocco under the rule of the Umayyad Caliphate and converting the indigenous Amazigh tribes to Islam, though they still retained their customary laws. In 740, spurred on by Kharijite agitators, the native Amazigh revolted against the caliphate. Morocco subsequently passed out of the caliphate's control and fragmented into a collection of small, independent Berber states such as Berghwata, Sijilmassa and Nekor. The Berbers went on to shape their own version of Islam. Some, like the Banu Ifran, retained their connection with radical puritan Islamic sects, while others, like the Berghwata, constructed a new syncretic faith. By the 11th century, a series of Amazigh dynasties rose to rule over all of Morocco, these included the Almoravids, Almohads, Marinids and Wattasids.
In the 16th century, Amazigh rule was displaced by the Arabic Saadi dynasty, which itself was succeeded by the Alaouite dynasty in the 17th century. But the centralized rule of the Alaouite Sultanate could not be totally extended throughout Moroccan territory, as many Amazigh tribes did not recognize the Sultan and did not submit to the government. These tribes organized federations from the bottom-up, in opposition to the central government, in which neighborhood representatives and village committees coordinated day-to-day affairs. Within these federations, property and the means of production were held collectively, where farms were worked on a cooperative basis without money exchanging hands. The Moroccan anarchist Brahim Filali examined the Amazigh federalism of pre-colonial Morocco and compared it to the modern-day concept of anarchist federalism, posing it as an example that could be drawn upon by African anarchists in their own organizing.
At the turn of the 20th century, Morocco was colonized by Spain and France, which divided the country into two European-controlled protectorates. The new governments faced resistance to colonial rule, particularly from Amazigh tribes, who were seeing their autonomy being stripped away. Early anti-colonial revolts were led by the Jebala and Izayen confederations, but the most prominent of these revolts culminated in the Rif War of the 1920s, in which Rifians led by Abd el-Krim briefly established a confederal republic and conducted a protracted guerilla war against the colonial regimes. However, the Republic of the Rif was eventually defeated and Abd el-Krim was exiled to Réunion. Resistance to colonial rule continued into the early 1930s, but was eventually crushed.
With the outbreak of the Spanish coup of July 1936, the nationalists seized control of the Spanish protectorate in Morocco. Many Moroccans were drafted into the Army of Africa to fight in the Spanish Civil War. In response, the anarchist newspaper Solidarid Obrera began to openly call for the self-determination of the Rif, drawing attention to the nationalists' "reign of terror" in Morocco, and urged workers in the Rif to prepare an armed insurrection against the nationalists.
In August 1936, Joan Garcia i Oliver met with the Egyptian teacher Marcelo Argila and sent him to Geneva in order to contact Moroccan nationalists. He returned in the company of the Moroccan Action Committee (MAC), which proposed to Garcia i Oliver a Moroccan uprising in exchange for a declaration of independence and the provision of arms and finances. The Central Committee of Antifascist Militias of Catalonia (CCMA) agreed to the terms, signing a pact with the MAC on September 20. Meanwhile, Pierre Besnard, secretary of the International Workers' Association (IWA), also proposed a plan to break Abd el-Krim out of his captivity on Réunion, but this too required a declaration of independence for Spanish Morocco to be secured. However, when a copy of the proposals were delivered to the republican government of Francisco Largo Caballero, the plan was rejected, in an attempt to avoid conflict with France. The CCMA was subsequently dissolved on October 1, and even when Garcia i Oliver and other leaders of the Confederación Nacional del Trabajo (CNT) joined the republican government, no major changes were made to the government's position on Morocco. In contrast, the nationalist commander Francisco Franco had been persuaded to grant certain freedoms to Moroccans, which included allowing the publication of an Arabic language newspaper.
Anti-Moroccan racism began to swell through the ranks of the republican faction, with Federica Montseny characterizing the military uprising in such terms: "if they were Spaniards, if they were patriots, they would not have unleashed the... Moors on Spain, imposing on Spain their fascistic civilisation, not as a Christian civilisation but a Moorish civilisation". When enemy soldiers were captured by republican forces, Moroccans faced particularly discriminatory levels of violence from their captors. Republican propaganda urged men to enlist in order to prevent Spanish women from being "despoiled by the Moors", in a move which was criticized by the anarcha-feminist Mujeres Libres. The editorial board of Solidaridad Obrera was also replaced with another, which began to propagate racist and even imperialist views in the paper.
In 1940, the Italian anarchist Celso Persici fled from the French authorities to Casablanca, where he joined the Moroccan resistance to fight against Fascist Italy in the Italian campaign. Following the end of World War II, the Mouvement libertaire nord-africain (MLNA) was established in French Algeria, with contacts in the French protectorates in Tunisia and Morocco. Guy-Virgile Martin was among the anarchist activists with a presence in the North African press, working as a teacher in Morocco, where he experienced the country's independence from France. In a letter sent to the Algerian anarchist Fernand Doukhan in January 1958, Martin described the isolation that anarchists were experiencing in the newly independent Morocco, which led him to join the Moroccan Communist Party, in which he became a leading figure.
With the founding of the Moroccan anarchist journal Ici et Maintenant in 2004, the editor Brahim Filali began to receive harassment and threats for his work, culminating in the journal's offices being set on fire on June 23, 2005. These acts of intimidation were met with condementation by Reporters Without Borders, which connected the harassment to the newspaper's support of a miners' strike in Imini. Filali appealed for support, which was taken up internationally by the General Confederation of Labor in Spain and Alternative libertaire in France, which helped to put together an appeal titled "Protect the freedom of the press in Morocco, support Brahim Fillali", which was signed by 20 French, Spanish and Moroccan organizations and communicated to the Moroccan press on August 5, 2005. Undeterred by the repression against the publication, Filali was among a group of Moroccan anarchists that established the Centre libertaire d'études et de recherches (CLER) in Rabat, which worked to "collect, classify and archive everything that has to do with anarchism", establishing a library, translating works into the Arabic language and organizing a number of events.