Moroccan nationalism refers to the nationalism of the Moroccans and Moroccan culture. Historically, it has been influenced by the conflicts between the Saadi Sultanate and European countries along with the Ottoman Empire, French and Spanish colonialism in Morocco, Salafism and Arab–Islamic nationalism.

The first manifestation of a Moroccan national identity was in the 16th century under the Saadi Sultanate. Moroccan nationalism first developed in the 1920s among urban intellectuals especially in Salafist circles in cities like Rabat, Fes and Tangier under European colonial rule. However, after the Berber Dahir, it began to encompass the masses and helped to organise the nationalist movement. In the 1930s, early nationalist organisations like the were formed to protest the Berber Dahir and seek reform. These nationalist figures eventually published the Moroccan Plan of Reforms.

After a split in the nationalist movement and the exile of several nationalist leaders, nationalists shifted their goal from reform of the protectorate in line with the Treaty of Fes to complete independence with Mohammed V as king. Several parties were formed at this time with the biggest being the Istiqlal Party. The Istiqlal published an Independence Manifesto laying out the nationalist movement's demands for independence. Around this time, Sultan Mohammed V became increasingly involved with the nationalist movement publicly aligning himself with the nationalists with the Tangier Speech. This eventually led to his deposition and exile by the French and grand caid and Pasha of Marrakesh Thami El Glaoui. The exile of Mohammed led to the rise of urban violence and rural violence with the establishment of the Moroccan Liberation Army. Thousands of attacks occurred in major cities like bombings and assassinations. This eventually led to Mohammed V returning and the French and Spanish leaving Morocco.

In 1956, the Istiqlal published a map depicting Greater Morocco, which covered the land they argued belonged to Morocco historically before colonialism. This irridentist claim later would influence the foreign policy in Morocco and play a role in their claim over the Western Sahara. The 1975 Green March led to Spain exiting the Western Sahara but it brought Morocco into conflict with the Polisario Front due to their competing nationalist claims.

Early manifestations

Formation of a national identity

Some historians attribute the formation of a distinct Moroccan national identity to the start of the 16th century. For example, the Moroccan historian Mohamed Hajji, attributing the beginning of Moroccan nationalism to the 16th to 17th centuries, argues that Moroccan resistance against Spanish and Portuguese incursions were the earliest examples of a Moroccan national consciousness. He backs this up further by pointing out how Morocco also resisted Ottoman expansion into Morocco despite being coreligionists showing that Moroccan self-conception also included a national consciousness superseding religious affiliations. The Saadis, who ruled at this time, are credited with this birth of a Moroccan national consciousness. "It is also to the credit of the Saʿdid s̲h̲urafāʾ that they presided over the birth of a genuine feeling of national consciousness, which resisted any attempt at domination by Christians or Ottomans." The historian Dahiru Yahaya argued that the most lasting impact of the Saadis was the development of this national consciousness in Morocco.

Hafidiya

The Hafidiya has been described by the cultural historian Edward Berenson as part "anticolonial struggle" and part "national rebellion". Tribes involved in the rebellion like the Rahamna sometimes went against their tribal interests and security to support the rebellion and national defence because they saw themselves as Moroccans.

Nationalism in the protectorate before the Dahir Throughout the 1920s, a number of scholars established the "free schools" () which combined reformist Islam and Western science based on the ideas of the Salafi movement and were independent of government control. The first free school was established in 1919. These free schools taught Classical Arabic and Islamic thought. The purpose of these was to cultivate a sense of national identity among urban youth and laid a cultural foundation for nationalism by "instilling national spirit—feeling of patriotism and a sense of Moroccan nationhood—in the students." By 1937, they provided primary education for 5000 students.

The prominent Moroccan nationalist figure Allal al-Fassi describing the development of early nationalism in Morocco and the influence of the Salafi movement says:

In the French zone, Moroccan nationalism developed in two different major cities: Fes and Rabat. In Fes, the nationalist groups that emerged were more religious, conservative and traditional in outlook while in Rabat, the groups had a more European outlook and ideology with many of their leaders having a modern education in France or Europe. However, this did not prevent the groups from working with another. For example, taking inspiration from nationalist movements in Egypt, Turkey and other parts of the Middle East and India, young nationalists started to form groups notably one in Rabat and one in Fes. The Rabat group, the Supporters of Truth, and the Fes group, the Students Union, joined to form to Moroccan League. This would later lead to the formation of the .

Moroccan Nationalist Movement

Emergence in response to the Berber Dahir

The Berber Dahir proved to be a "foundational event in the unfolding story of Moroccan nationalism" according to the historian Susan Gilson Miller. Before 1930, the Moroccan nationalist movement lacked unity, a formal organisation structure and a clear programme. The Berber Dahir attempted to place Berber tribal areas under customary law officially rather than Sharia. This Dahir also made it so that criminal cases would by judged under French law rather under Islamic law. This was seen by Arab elites as an attempt to divide Arabs and Berbers and an attack on Islam. There were also rumours that it was an attempt to convert the Berbers into Catholicism. According to some, the Berber Dahir allowed Moroccan nationalism to evolve from a small cadre of intellectuals to a popular political movement. It also shifted the emphasis of national activity from cultural to political.

In response to the Dahir, nationalists like Ahmed Balafrej and Allal al-Fassi began to coordinate. Nationalist leaders like Allal al-Fassi, Ahmed Balafrej, and Mohammed Hassan Ouazzani established a network of connections with nationalists in Algeria and Tunisia, many of whom belong to the founded in 1927. The protests that emerged in response to the Dahir including the recitation of latif prayers, a prayer usually recited in times of crisis. The scholar Emily Benichou Gottreich says "the latif prayer marks the first mass manifestation of modern nationalism in Morocco." The words of the latif prayer were modified for the context of the protest with the additional of a special ending:

In August 1930, activists from Salé, Rabat, Tetouan and Fes formed the Zawiya a steering committee composed of the most important nationalist leaders. There was also a larger group called the Taifa or the "Outer Circle". Membership in the Taifa required an oath of allegiance and the payment of dues. The oath involved a prospective member putting his finger on the Qad-sami chapter of the Quran and saying "I swear by God and the Qur'an that I will follow the orders of the Wataniyin." This movement adopted the nomenclature, structure and religious undertones of Sufi orders for their own organisation. In rural areas especially, they adopted a master-discipline relationship like Sufi orders and competed with Sufi orders like the Qadiriyya and Tijaniyya. After the movement split in 1936, those that followed Allal al-Fassi were referred to often as the Allaliyin, with al-Fassi referred to as Shaykh Allal or Hajj Allal. The political scientist John Waterbury argues that "Nationalism [in Morocco] made no real and important progress until it took the form of a religious brotherhood, the 'nationalist zawiya,' and until ʿAllal al-Fassi became Shaykh ʿAllal." Another organisation that formed from the protest movement against the Dahir was the (; CAM) also known as the National Action Bloc (; or the Kutla). The Kutla reached 6500 members before it disbanded in 1937. Its president was Allal al-Fassi and its secretary was Mohammed Hassan Ouazzani.

The Kutla published the Plan of Reforms () in 1934 in both Arabic and French. The demands of the reform plan included the abolition of the Berber Dahir, unification of legal systems under Maliki law, expansion of the education system open to Moroccans, the forming of municipal councils, the promotion of Moroccans into positions of power and making Arabic an official language. The reform plan did not outright call for independence but sought reform and the restoring of confidence in the aims of the 1912 Treaty of Fes.. "Strikingly, the Plan did not call for an independent Morocco or separation from France; instead, it aimed at " restoring confidence in the work of France in Morocco " and demanded greater Moroccan participation in government, a more cooperative relationship with the Residency, and a more faithful execution of the provisions of the 1912 Treaty of Fez...The decision to work within the framework of the Residency was sincere, for at that moment, the nationalist leadership still did not visualize Morocco without France. But that did not mean a relationship of servility or abuse. At a fundamental level, the Plan launched a frontal assault on the colonial mentality and the corrupt practices it had engendered; namely, the racism, discrimination, and anti-liberalism that allowed Moroccans to be treated as inferiors.". "It summarized their reformist agenda, which still accepted and assumed a Franco-Moroccan protectorate framework but appealed to the "protector" to do a better job of fulfilling the mandate of the Treaty of Fes.". "The Plan de Réformes called not for independence but for a true application of the Treaty of Fez, a real Protectorate. Its long preamble explained that Moroccan sovereignty had not been extinguished in 1912, and that under the treaty, the Sultan continued to embody the Moroccan identity. The purpose of the Protectorate was reform, which was also the wish of the Moroccan population, so that a 'real' Protectorate was therefore a democratic demand. Nowhere was there any recognition of a possible conflict between these democratic ideals and the authority of the Sultan." The ten signatories of the reform plan were all from the French protectorate and included nationalists like Mohammed Hassan Ouazzani and Allal al-Fassi. Allal al-Fassi discussing the reform plan says:

On 1 December, Omar Benabdeljalil, and Mohammed Hassan Ouazzani presented the plan to the French foreign minister, Pierre Laval. In Rabat, Mohamed Ghazi presented a copy to the Sultan and Lyazidi, and Allal al-Fassi took it the Resident-General. While the plan had support from some French politicians like , César Campinchi and Georges Monnet, the plan was rejected by the French administration and the French Resident-General Henri Ponsot dismissively described it as a "good doctoral thesis" without making any serious comment on its ideas. This dismissive attitude held by the French did not change throughout the decade. This rejection sparked street demonstrations in cities like Fes and Kenitra in November 1936 and 1937.