# Alawi Sultanate

The Alawi Sultanate, officially known as the Sharifian Sultanate (Arabic: السلطنة الشريفة) and as the Sultanate of Morocco, was the state ruled by the 'Alawi dynasty over what is now Morocco, from their rise to power in the 1660s to the 1912 Treaty of Fes that marked the start of the French protectorate.
The dynasty, which remains the ruling monarchy of Morocco today, originated from the Tafilalt region and rose to power following the collapse of the Saadi Sultanate in the 17th century. Sultan al-Rashid (r. 1666–1672) was the first to establish his authority over the entire country. The sultanate reached an apogee of political power during the reign of his successor, Moulay Isma'il (r. 1672–1727), who exercised strong central rule.
After Isma'il's death, Morocco underwent periods of turmoil and renewal under different sultans. A long period of stability returned under Sidi Mohammed ibn Abdallah (r. 1757–1790). Regional stability was disrupted by the French invasion of Algeria in 1830 and thereafter Morocco faced serious challenges from European encroachment in the region.
Morocco remained independent under 'Alawi rule until 1912, when it was placed under the control of a French protectorate. The 'Alawi sultans continued to act as nominal monarchs under French colonial rule until Morocco regained independence in 1956, with the Alawi sultan Mohammed V as its sovereign. In 1957, Mohammed V formally adopted the title of "King" and Morocco is now officially known as the Kingdom of Morocco.

## Name and etymology

Morocco, since the rule of the Saadi dynasty, was sometimes referred to as the Sharifian Sultanate as a reference to the ruling dynasty's claim to noble ancestry. This was rendered in French as l'Empire chérifien (Arabic: الإيالة الشريفة; lit. 'the Sharifian empire') according to the Treaty of Fes. This name was still in official usage until 1956 when Morocco regained its independence from colonial rule. It was also referred to as Sultanate of Morocco in English, including in the Anglo-Moroccan Treaty of 1856.
The Alawi dynasty claims descent from Muhammad via Hasan, the son of Ali. The name 'Alawi (Arabic: علوي) stems either from the name of Ali, from which the dynasty ultimately traces its descent, or from the name of the dynasty's early founder Ali al-Sharif of the Tafilalt.

## History
### Origins

The ruling dynasty of the Sultanate, the Alawis (lit. 'descendants of Ali'; sometimes rendered Filali Sharifs), rose from the settlement of Sijilmassa in the eastern oasis of Tafilalt. Little is known of their history prior to the 17th century, but by this century they had become the main leaders of the Tafilalt.
The Alawis are believed to have been descendants of immigrants from Yanbu in the Hejaz who settled in North Africa during a drought that affected the region in the 13th century. The dynasty claims descent to the Prophet Muhammad through his grandson Hasan, the son of Ali and Muhammad's daughter Fatima.
Their status as shurafa (descendants of the Prophet) was part of the reason for their success, as in this era many communities in Morocco increasingly saw sharifian status and noble lineage as the best claim to political legitimacy. The Saadian dynasty, which ruled Morocco during the 16th century and preceded the 'Alawis, also claimed sharifian lineage and played an important role in engraining this model of political-religious legitimacy in Moroccan society.$^{:228}$
The patriarch of the dynasty is believed to be Moulay Hassan ben al-Qasim ad-Dakhil, who established a religious aristocracy with his sharifian lineage throughout the oasis. Known for his deep piety, he was believed to have moved to Sijilmassa in 1265 under the rule of the Marinids at the request of locals who promoted him as imam of Tafilalt and viewed the presence of sharifs in the region as beneficial for religious legitimity.
He left behind a son, Mohamed, who in turn had only one descendant who bore the same name as his grandfather. One of this descendant's sons, Moulay Ali Cherif [fr], undertook the pilgrimage to Mecca and participated in the Moroccan–Portuguese wars of the 16th century and was also invited by the Nasrids to fight against Castile in the Iberian Peninsula during the Granada War. He declined to settle in Granada at the request of scholars in the city but rather settled for many years in Fez and Sefrou before returning to Tafilalt.

### Rise to power

The family's rise to power took place in the context of early-to-mid-17th century Morocco, when the power of the Saadian sultans of Marrakesh was in serious decline and multiple regional factions fought for control of the country. Among the most powerful of these factions were the Dala'iyya (also spelled Dila'iyya or Dilaites), a federation of Amazigh (Berbers) in the Middle Atlas who increasingly dominated central Morocco at this time, reaching the peak of their power in the 1640s. Another, was 'Ali Abu Hassun al-Semlali (or Abu Hassun), who had become leader of the Sous valley since 1614.$^{:222,228}$ When Abu Hassun extended his control to the Tafilalt region in 1631, the Dala'iyya in turn sent forces to enforce their own influence in the area. The local inhabitants chose as their leader the head of the 'Alawi family, Muhammad al-Sharif – known as Mawlay Ali al-Sharif, Mawlay al-Sharif, or Muhammad I – recognizing him as Sultan.$^{:222,228}$ Mawlay al-Sharif led an attack against Abu Hassun's garrison at Tabu'samt in 1635 or 1636 (1045 AH) but failed to expel them. Abu Hassun forced him to go into exile to the Sous valley, but also treated him well; among other things, Abu Hassun gifted him a slave concubine who later gave birth to one of his sons, Mawlay Isma'il.$^{:228}$$^{:224}$
While their father remained in exile, al-Sharif's sons took up the struggle. His son Sidi Mohammed (or Muhammad II), became the leader after 1635 and successfully led another rebellion which expelled Abu Hassun's forces in 1640 or 1641 (1050 AH). With this success, he was proclaimed sultan in place of his father who relinquished the throne to him.$^{:228–229}$$^{:224–225}$ However, the Dala'iyya invaded the region again in 1646 and following their victory at Al Qa'a forced him to acknowledge their control over all the territory west and south of Sijilmasa. Unable to oppose them, Sidi Mohammed instead decided to expand in the opposite direction, to the northeast.$^{:228–229}$$^{:224–225}$$^{:22}$ He advanced as far as al-Aghwat and Tlemcen in Algeria in 1650. His forays into Algeria provoked a response from the leaders of the Ottoman Regency of Algiers, who sent an army that chased him back to Sijilmasa. In negotiations with a legation from Algiers, Sidi Mohammed agreed not to cross into Ottoman territory again and the Tafna River was set as their northern border.$^{:79}$$^{:228–229}$$^{:224–225}$ In 1645 and again in 1652, Sidi Mohammed also imposed his rule on Tuat, an oasis in the Sahara to the southeast.$^{:232}$
Despite some territorial setbacks, the 'Alawis' influence slowly grew, partly thanks to their continued alliance with certain Arab tribes of the region. In June 1650, the leaders of Fez (or more specifically Fes el-Bali, the old city), with the support of the local Arab tribes, rejected the authority of the Dala'iyya and invited Sidi Mohammed to join them. Soon after he arrived, however, the Dala'iyya army approached the city and the local leaders, realizing they did not have enough strength to oppose them, stopped their uprising and asked Sidi Mohammed to leave.$^{:229}$
Al-Sharif died in 1659, and Sidi Mohammed was once again proclaimed sovereign. However, this provoked a succession clash between Sidi Mohammed and one of his younger half-brothers, al-Rashid. Details of this conflict are lengthy, but ultimately Al-Rashid appears to have fled Sijilmasa in fear of his brother and took refuge with the Dala'iyya in the Middle Atlas. He then moved around northern Morocco, spending time in Fez, before settling in Angad (northeastern Morocco today). He managed to secure an alliance with the same Banu Ma'qil Arab tribes who had previously supported his brother and also with the Ait Yaznasin (Beni Snassen), a Zenata Amazigh tribe. These groups recognized him as sultan in 1664, while around the same time Sidi Mohammed made a new base for himself as far west as Azrou. The power of the Dala'iyya was in decline, and both brothers sought to take advantage of this, but both stood in each other's way. When Sidi Mohammed attacked Angad to force his rebellious brother's submission on August 2, 1664, he was instead unexpectedly killed and his armies defeated.$^{:229}$$^{:225}$
By this time, the Dala'iyya's realm, which once extended over Fez and most of central Morocco, had largely receded to their original home in the Middle Atlas. Al-Rashid was left in control of the 'Alawi forces and in less than a decade he managed to extend 'Alawi control over almost all of Morocco, reuniting the country under a new sharifian dynasty.$^{:229}$ Early on, he won over more rural Arab tribes to his side and integrated them into his military system. Also known as guich tribes ("Army" tribes, also transliterated as gish), they became one of his most important means of imposing control over regions and cities. In 1664 he had taken control of Taza, but Fez rejected his authority and a siege of the city in 1665 failed. After further campaigning in the Rif region, where he won more support, Al-Rashid returned and secured the city's surrender in June 1666.$^{:230}$$^{:83}$ He made the city his capital, but settled his military tribes in other lands and in a new kasbah outside the city (Kasbah Cherarda today) to head off complaints from the city's inhabitants about their behaviour. He then defeated the remnants of the Dala'iyya by invading and destroying their capital in the Middle Atlas in June 1668. In July he captured Marrakesh from Abu Bakr ben Abdul Karim Al-Shabani, the son of the usurper who had ruled the city since assassinating his nephew Ahmad al-Abbas, the last Saadian sultan.$^{:230}$ Al-Rashid's forces took the Sous valley and the Anti-Atlas in the south, forced Salé and its pirate republic to acknowledge his authority, while in the north, except for the European enclaves, he was in control of all the Rif comprising Ksar al-Kebir, Tetouan and Oujda in the northeast. Al-Rashid had thus succeeded in reuniting the country under one rule. He was not able to enjoy this success for very long, however, and died young in 1672 while in Marrakesh.$^{:225}$

### The reign of Mawlay Isma'il

Upon Al-Rashid's death his younger half-brother Mawlay Isma'il became sultan. As sultan, Isma'il's 55-year reign was one of longest in Moroccan history. He distinguished himself as a ruler who wished to establish a unified Moroccan state as the absolute authority in the land, independent of any particular group within Morocco – in contrast to previous dynasties which relied on certain tribes or regions as the base of their power.$^{:230}$ He succeeded in part by creating a new army composed of Black slaves (the 'Abid al-Bukhari) from Sub-Saharan Africa (or descendants of previously imported slaves), many of them Muslims, whose loyalty was to him alone. Mawlay Isma'il himself was half Black, his mother having been a Black slave concubine of Muhammad al-Sharif.$^{:231}$ This standing army also made effective use of modern artillery. He continuously led military campaigns against rebels, rivals, and European positions along the Moroccan coast. In practice, he still had to rely on various groups to control outlying areas, but he nonetheless succeeded in retaking many coastal cities occupied by England and Spain and managed to enforce direct order and heavy taxation throughout his territories. He put a definitive end to Ottoman attempts to gain influence in Morocco and established Morocco on more equal diplomatic footing with European powers in part by forcing them to ransom Christian captives at his court. These Christians were mostly captured by Moroccan pirate fleets which he heavily sponsored as a means of both revenue and warfare. While in captivity, prisoners were often forced into labour on his construction projects. All of these activities and policies gave him a reputation for ruthlessness and cruelty among European writers and a mixed reputation among Moroccan historians as well, though he is credited with unifying Morocco under strong (but brutal) leadership.$^{:230–237}$$^{:225–230}$
He also moved the capital from Fez to Meknes, where he built a vast imperial kasbah, a fortified palace-city whose construction continued throughout his reign. He also built fortifications across the country, especially along its eastern frontier, which many of his 'Abid troops garrisoned. This was partly a response to continued Turkish interference in Morocco, which Isma'il managed to stop after many difficulties and rebellions.$^{:231–232}$ Al-Khadr Ghaylan, a former leader in northern Morocco who fled to Algiers during Al-Rashid's advance, returned to Tetouan at the beginning of Isma'il's reign with Algerian help and led a rebellion in the north which was joined by the people of Fez. He recognized Isma'il's nephew, Ahmad ibn Mahriz, as sultan, who in turn had managed to take control of Marrakesh and was recognized also by the tribes of the Sous valley. Ghaylan was defeated and killed in 1673, and a month later Fez was brought back under control. Ahmad ibn Mahriz was only defeated and killed in 1686 near Taroudant.$^{:231–232}$ Meanwhile, the Ottomans supported further dissidents via Ahmad al-Dala'i, the grandson of Muhammad al-Hajj who had led the Dala'iyya to dominion over a large part of Morocco earlier that century, prior to Al-Rashid's rise. The Dala'is had been expelled to Tlemcen but and they returned to the Middle Atlas at the instigation of Algiers and under Ahmad's leadership in 1677. They managed to defeat Isma'il's forces and control Tadla for a time, but were defeated in April 1678 near Wadi al-'Abid. Ahmad al-Dala'i escaped and eventually died in early 1680.$^{:231–232}$ After the defeat of the Dala'is and of his nephew, Isma'il was finally able to impose his rule without serious challenge over all of Morocco and was able to push back against Ottoman influence. After Ghaylan's defeat, he sent raids and military expeditions into Algeria in 1679, 1682, and 1695–96.$^{:232}$$^{:226}$ A final expedition in 1701 ended poorly.$^{:226}$ Peace was re-established and the two sides agreed to recognize their pre-existing mutual border.$^{:232}$$^{:226}$
Isma'il also sought to project renewed Moroccan power abroad and in former territories. Following the decline of central rule in the late Saadian period earlier that century, the Pashalik of Timbuktu, created after Ahmad al-Mansur's invasion of the Songhai Empire, had become de facto independent and the trans-Saharan trade routes fell into decline. The 'Alawis had become masters over Tuat in 1645, which rebelled many times after this but Isma'il established direct control there from 1676 onwards.$^{:232}$ In 1678–79 he organized a major military expedition to the south, forcing the Emirates of Trarza and Brakna to become his vassals and extending his overlordship up to the Senegal River.$^{:227}$ In 1694 he appointed a qadi to control in Taghaza (present-day northern Mali) on behalf of Morocco.$^{:232}$ Later, in 1724, he sent an army to support the amir of Trarza (present-day Mauritania) against the French presence in Senegal and also used the opportunity to appoint his own governor in Shinqit (Chinguetti).$^{:232}$ Despite this reassertion of control, trans-Saharan trade did not resume in the long-term on the same levels it existed before the 17th century.
In 1662 Portuguese-controlled Tangier was transferred to English control as part of Catherine of Braganza's dowry to Charles II of England. Mawlay Isma'il unsuccessfully besieged the city in 1680, but this pressure, along with attacks from local Muslim mujahidin (also known as the "Army of the Rif"), led the English to evacuate Tangier in 1684. Mawlay Isma'il immediately claimed the city and sponsored its Muslim resettlement, but granted local authority to 'Ali ar-Rifi, the governor of Tetouan who had played an active part in besieging the city and became the chieftain of northern Morocco around this time.$^{:239}$ Isma'il also conquered Spanish-controlled Mahdiya in 1681, Al-Ara'ish (Larache) in 1689, and Asilah in 1691.$^{:226}$ Moreover, he sponsored Moroccan pirates which preyed on European merchant ships. Despite this, he also allowed Europeans merchants to trade inside Morocco, but he strictly regulated their activities and forced them to negotiate with his government for permission, allowing him to efficiently collect taxes on trade. Isma'il also allowed European countries, often through the proxy of Spanish Franciscan friars, to negotiate ransoms for the release of Christians captured by pirates or in battle. He also pursued relations with Louis XIV of France starting in 1682, hoping to secure an alliance against Spain, but France was less interested in this idea and relations eventually collapsed after 1718.$^{:232–233}$

### Disorder and civil war under Isma'il's sons

After Mawlay Isma'il's death, Morocco was plunged into one of its greatest periods of turmoil between 1727 and 1757, with Isma'il's sons fighting for control of the sultanate and never holding onto power for long. Isma'il had left hundreds of sons who were theoretically eligible for the throne. Conflict between his sons was compounded by rebellions against the heavily taxing and autocratic government which Isma'il had previously imposed. Furthermore, the 'Abid of Isma'il's reign came to wield enormous power and were able to install or depose sultans according to their interests throughout this period, though they also had to compete with the guich tribes and some of the Amazigh (Berber) tribes.$^{:237–238}$ Meknes remained the capital and the scene of most of these political changes, but Fez was also a key player.$^{:237–238}$ Ahmad adh-Dhahabi was the first to succeed his father but was immediately contested and ruled twice only briefly before his death in 1729, with his brother Abd al-Malik ruling in between his reigns in 1728. After this his brother Abdallah ruled for most of the period between 1729 and 1757 but was deposed four times.$^{:237–238}$ Abdallah was initially supported by the 'Abid but eventually made enemies of them after 1733. Eventually he was able to gain advantage over them by forming an alliance with the Amazigh tribe of Ait Idrasin, the Oudaya guich tribe, and the leaders of Fez (whom he alienated early on but later reconciled with).$^{:238}$ This alliance steadily wore down the 'Abid's power and paved the way for their submission in the later part of the 18th century.$^{:238–240}$
In this period, the north of Morocco also became virtually independent of the central government, being ruled instead by Ahmad ibn 'Ali ar-Rifi, the son of 'Ali al-Hamami ar-Rifi whom Mawlay Isma'il had granted local authority in the region of Tangier.$^{:239}$ Ahmad al-Hamami ar-Rifi used Tangier as the capital of his territory and profited from an arms trade with the British at Gibraltar, with whom he also established diplomatic relations. Sultan Ahmad al-Dahabi had tried to appoint his own governor in Tetouan to undermine Ar-Rifi's power in 1727, but without success. Ahmad ar-Rifi was initially uninterested in the politics playing out in Meknes, but became embroiled due to an alliance he formed with al-Mustadi', one of the ephemeral sultans installed by the 'Abid installed in May 1738. When Al-Mustadi' was in turn deposed in January 1740 to accommodate Abdallah's return to power, Ar-Rifi opposed the latter and invaded Fez in 1741. Mawlay Abdallah's alliance of factions was able to finally defeat and kill him on the battlefield in 1743, and soon after the sultan's authority was re-established along the coastal cities of Morocco.$^{:239}$ In 1647, Abdallah strategically established his two sons as Khalifa (Viceroy) in politically important cities. His eldest Mawlay Ahmed was appointed Khalifa of Rabat and his youngest. Sidi Mohammed, Khalifa of Marrakesh. His eldest son would die before him in 1750. After 9 years of uninterrupted reign, Abdallah died at Dar Dbibegh on November 10, 1757.

### Restoration of authority under Mohammed ibn Abdallah

Order and control was firmly re-established only under Abdallah's son, Sidi Mohammed ibn Abdallah (Mohammed III), who became sultan in 1757 after a decade as viceroy in Marrakesh. Many of the 'Abid had by then deserted their contingents and joined the common population of the country, and Sidi Mohammed III was able to reorganize those who remained into his own elite military corps.$^{:239–240}$ The Oudaya, who had supported his father but had been a burden on the population of Fez where they lived, became the main challenge to the new sultan's power. In 1760 he was forced to march with an army to Fez where he arrested their leaders and destroyed their contingents, killing many of their soldiers. In the aftermath the sultan created a new, much smaller, Oudaya regiment which was given new commanders and garrisoned in Meknes instead.$^{:240}$ Later, in 1775, he tried to distance the 'Abid from power by ordering their transfer from Meknes to Tangier in the north. The 'Abid resisted him and attempted to proclaim his son Yazid (the later Mawlay Yazid) as sultan, but the latter soon changed his mind and was reconciled with his father. After this, Sidi Mohammed III dispersed the 'Abid contingents to garrisons in Tangier, Larache, Rabat, Marrakesh and the Sous, where they continued to cause trouble until 1782. These disturbances were compounded by drought and severe famine between 1776 and 1782 and an outbreak of plague in 1779–1780, which killed many Moroccans and forced the sultan to import wheat, reduce taxes, and distribute food and funds to locals and tribal leaders in order to alleviate the suffering. By now, however, the improved authority of the sultan allowed the central government to weather these difficulties and crises.$^{:240}$
Sidi Mohammed ibn Abdallah maintained the peace in part through a relatively more decentralized regime and lighter taxes, relying instead on greater trade with Europe to make up the revenues. In line with this policy, in 1764 he founded Essaouira, a new port city through which he funneled European trade with Marrakesh. The last Portuguese outpost on the Moroccan coast, Mazagan (El Jadida today), was taken by Morocco in 1729, leaving only the Spanish enclaves of Ceuta and Melilla as the remaining European outposts in Morocco. Muhammad also signed a Treaty of Friendship with the United States in 1787 after becoming the first head of state to recognize the new country. He was interested in scholarly pursuits and also cultivated a productive relationship with the ulama, or Muslim religious scholars, who supported some of his initiatives and reforms.$^{:241}$
Sidi Mohammed's opening of Morocco to international trade was not welcomed by some, however. After his death in 1790, his son and successor Mawlay Yazid ruled with more xenophobia and violence, punished Jewish communities, and launched an ill-fated attack against Spanish-held Ceuta in 1792 in which he was mortally wounded. After his death, he was succeeded by his brother Suleyman (or Mawlay Slimane), though the latter had to defeat two more brothers who contested the throne: Maslama in the north and Hisham in Marrakesh to the south. Suleyman brought trade with Europe nearly to a halt.$^{:260}$ Although less violent and bigoted than Yazid, he was still portrayed by European sources as xenophobic. Some of this lack of engagement with Europe was likely a consequence of the French Revolutionary and Napoleonic Wars, during which the Royal Navy blockaded France and Spain, both of whom threatened Morocco into not taking sides in the conflict. After 1811, Suleyman also pushed a fundamentalist Wahhabist ideology at home and attempted to suppress local Sufi orders and brotherhoods, in spite of their popularity and despite his own membership in the Tijaniyya order.$^{:260}$

### European encroachment and reforms

Suleyman's successor, Abd al-Rahman (r. 1822–1859), tried to reinforce national unity by recruiting local elites of the country and orchestrating military campaigns designed to bolster his image as a defender of Islam against encroaching European powers. The French conquest of Algeria in 1830, however, destabilized the region and put the sultan in a very difficult position. It marked a major shift in Morocco's diplomatic and military situation. Until then, European powers had been an intermittent concern, but now they became a permanent presence whose influence grew in politics, the economy, and society.$^{:7}$$^{:264}$ French conquests in the region progressively surrounded Morocco afterwards, while colonial encroachment on Morocco itself was slowed mainly due to rivalries between the European powers.$^{:264}$
Wide popular support for the Algerians against the French invasion led Morocco to allow the flow of aid and arms to the resistance movement led by Emir Abd al-Qadir, while the Moroccan ulama delivered a fatwa for supporting jihad in 1837. On the other hand, Abd al-Rahman was reluctant to provide the French with a clear reason to attack Morocco if he ever intervened. He managed to maintain the appearance of neutrality until 1844, when he was compelled to provide refuge to Abd al-Qadir in Morocco. The French, led by the marshall Bugeaud, pursued him and thoroughly routed the Moroccan army at the Battle of Isly, near Oujda, on August 14. At the same time, the French navy bombarded Tangiers on August 6 and bombarded Mogador (Essaouira) on August 16. In the aftermath, Morocco signed the Convention of Lalla Maghnia on March 18, 1845. The treaty made the superior power of France clear and forced the sultan to recognize French authority over Algeria. Abd al-Qadir turned rebel against the sultan and took refuge in the Rif region until his surrender to the French in 1848.$^{:264–265}$
Between 1848 and 1865, Britain, France and Spain competed for influence in Morocco. Britain sought to keep France at bay in the region, especially since Morocco was next to Gibraltar.$^{:22}$ British consul John Hay Drummond Hay pressured Abd ar-Rahman into signing the Anglo-Moroccan Treaty of 1856, which removed government restrictions on trade and granted special privileges to the British. Among the latter was the establishment of a protégé system whereby Britain could extend legal protection to individuals within Morocco.$^{:23}$ British influence in Morocco encouraged other European powers to replicate their success. The Spanish government was eager to expand its presence in Africa in order to distract from its own domestic difficulties.$^{:24}$ The next direct confrontation between Morocco and Europe was the Hispano-Moroccan War, which took place from 1859 to 1860. The subsequent Treaty of Wad Ras led the Moroccan government to take a massive British loan larger than its national reserves to pay off its war debt to Spain.$^{:24–27}$
Right before the war, Abd al-Rahman died and was succeeded by his son Muhammad IV (r. 1859–1873). Following the war, the new sultan was determined to follow a policy of reforms to address the state's weaknesses. These reforms took place progressively and in a piecemeal fashion.$^{:28–29}$ The sultan tried to increase revenues by streamlining the taxation of Morocco's fertile regions, forcing the payment of an annual fixed sum instead of the more flexible taxation regime that existed earlier. This was more efficient but it took a heavy toll on the rural economy and the food security of its population.$^{:30–31}$ At the same time, the urban population grew along with international trade, which fostered the emergence of an urban bourgeoisie, both Muslim and Jewish, who spurred further social changes.$^{:31–32}$ Despite this growth, the state remained in financial difficulties, in part due to the devaluation of the Moroccan currency.$^{:32–33}$
Muhammad IV also reorganized the state and began to institutionalize a more professional, regular administration and military, often by following Western European models. This trend was taken further by his talented successor, Hassan I (r. 1873–1894).$^{:33–41}$$^{:304}$ Hassan I also campaigned tirelessly to collect tax revenues and reimpose central rule on outlying provinces.$^{:304–305}$$^{:41–42}$
In the latter part of the 19th century Morocco's instability resulted in European countries intervening to protect investments and to demand economic concessions. Hassan I called for the Madrid Conference of 1880 in response to France and Spain's abuse of the protégé system, but the result was an increased European presence in Morocco—in the form of advisors, doctors, businessmen, adventurers, and even missionaries.$^{:47}$

### Crisis and installation of French and Spanish Protectorates

After Sultan Abdelaziz appointed his brother Abdelhafid as viceroy of Marrakesh, the latter sought to have him overthrown by fomenting distrust over Abdelaziz's European ties. Abdelhafid was aided by Madani el-Glaoui, older brother of T'hami, one of the Caids of the Atlas. He was assisted in the training of his troops by Andrew Belton, a British officer and veteran of the Second Boer War. For a brief period, Abdelaziz reigned from Rabat while Abdelhafid reigned in Marrakesh and Fez and a conflict known as the Hafidiya (1907–1908) ensued. In 1908 Abdelaziz was defeated in battle. In 1909, Abdelhafid became the recognized leader of Morocco.
In 1911, rebellion broke out against the sultan. This led to the Agadir Crisis, also known as the Second Moroccan Crisis. These events led Abdelhafid to abdicate after signing the Treaty of Fes on 30 March 1912, which made Morocco a French protectorate. He signed his abdication only when on the quay in Rabat, with the ship that would take him to France already waiting. When news of the treaty finally leaked to the Moroccan populace, it was met with immediate and violent backlash in the Intifada of Fez. His brother Youssef was proclaimed Sultan by the French administration several months later (13 August 1912). At the same time a large part of northern Morocco was placed under Spanish control.

## Government and politics

Moroccan authors during the Sultanate classified it as both being a caliphate and an imamate. Morocco was led by an absolute monarchy, with no clear rules of succession.

### Makhzen

The governing administration in Morocco, known as the Makhzen (lit. 'warehouse'), was an hierarchical administration which ruled under Islamic law. The authority of the Sultan in Morocco were both political and religious, with his authority revolving around his title of Commander of the Faithful (amir al-muminin) and oaths of allegiance (bayahs) made by tribes to the Sultan.
The Sultanate was divided into provinces led by pashas and regions led by caids, which were all appointed by the Makhzen and were described as "local despots" by Robert Montagne [fr].
These caids were unpaid until 1856, when Hay proposed that Sultan Mohammed IV give government workers wages from the Makhzen's treasury. A few caids consolidated power and embraced despotism, establishing a form of oligarchy involving three families: the El Glaoui (through Madani El Glaoui), Gontafi and Mtouggi clans.
The extent of the Sultan's authority was classified in two categories mainly based on taxation. Bled el-Makhzen (lit. 'land of the Makhzen'), which included most of the country's Atlantic coast and urban areas and was directly governed and taxed by the Makhzen under the direct rule of the Sultan. In contrast, Bled es-Siba (lit. 'land of anarchy') held tribal autonomy and self-governance but held an oath of allegiance to the Sultan and recognized his religious and spiritual status but refused to pay taxes to the Makhzen.
Despite this, the distinction between Bled el-Makhzen and Bled es-Siba remained vague and fluctuated. The decision by some tribes to refuse to pay taxes to the Makhzen were sometimes used as a bargaining chip to obtain favors rather than dissent from the Sultan. In many cases, governors in Bled es-Siba reported their investiture to the Sultan.

### Judiciary

In Bilad el-Makhzen, common law matters and some civil and criminal cases were judged by courtrooms which ruled by Islamic law and were presided by a qadi (judge), where parties could choose an oukil (council; equivalent to a lawyer) to represent them in court and present fatwas (advisories) written by a faqih (jurist) using Islamic jurisprudence to present their case or defense. After the sentence was pronounced, a governor for the Makhzen was charged with enforcing the decision. Contracts and marriage certificates were registered by two adouls (notaries) and were signed also signed by a qadi.
Most civil and criminal cases were judged by a courtroom ran by the Makhzen and led by a pasha (governor) or a qaid (commander) which enforced tazir punishements in criminal cases. The Makhzen courts were often favored over religious courts due to their speedy trials. However, the jurisdiction of the quasi-secular Makhzen courts and the religious courts often overlapped and a party in a Makhzen dispute could request to raise the case to a religious court. The death sentence could only be ruled with the authorization of the Sultan.
Moroccan Jews were given judicial autonomy and were allowed to set up courtrooms which enforced Hebraic law and rabbinical jurisprudence among themselves. However, Islamic religious courts were favored to judge in cases involving both Jews and Muslims. Matters involving Europeans were judged by the consul of their home countries. If a Moroccan was subject to a lawsuit from a European, the consul would file the complaint to a Makhzen courthouse on behalf of the European complainant.
Within Bled es-Siba, a number of rural courtrooms were set up by tribes in Morocco which judged based on a mix of Berber customary law and Islamic law. These included arbitrational "court of laws" in villages for civil disputes and tribal "court of appeals" in criminal or appellate case. In some cases, complainants were authorized to enforce legal rulings in their favor through means of violence.

### Flag

The Alawis are said to have adopted a plain red flag in the 17th century. Such a red flag was still being used until 1915, when a green star was added to the current Moroccan flag. Different origins have been proposed for the red flag. Moroccan researcher Nabil Mouline has suggested that it was adopted when Sultan al-Rashid captured Rabat, which was inhabited at the time by Andalusians who used the red flag. Others have claimed that the red colour represents the Alawis' claim of sharifian descent, much like the Sharifs of Mecca (who also claimed descent from the Islamic prophet Muhammad) used a red flag. Nabil Mouline suggests that the Alawis also used a green flag.

## Religion

Islam in Morocco was primarily defined by Maliki doctrine intertwined with Sufism.
Inspired by Wahhabism, a crackdown on Sufi brotherhoods and mystical orders (tariqas) in the country was led by Moulay Slimane for practices he deemed to be sinful. This crackdown stopped under the reign of Moulay Abderrahmane ben Hisham, which helped him consolidate his rule.

## Culture
### Literature

One of the main literary genres of Morocco during this period were works devoted to describing the history of local Sufi "saints" and teachers, which were common since the 14th century. Such works from Fez, for example, are especially abundant from the 17th to 20th centuries.$^{:54,108}$
During the 18th century, a number of Tachelhit poets arose including Muhammad ibn Ali al-Hawzali in Taroudant and Sidi Hammou Taleb in Moulay Brahim. Ahmed at-Tijani (d. 1815), originally from Aïn Madhi in Algeria, lived in Fez and later established the Tijaniyyah Sufi order. He was associated with the North African literary elite and the religious scholars of the Tijaniyyah order were among the most prolific producers of literature in the Maghreb.
Towards the beginning of the 20th century, Moroccan literature began to diversify, with polemic or political works becoming more common at this time. For example, there were Muhammad Bin Abdul-Kabir Al-Kattani's anti-colonial periodical at-Tā'ūn (Arabic: الطاعون, lit. 'The Plague'), and his uncle Muhammad ibn Jaqfar al-Kattani's popular Nasihat ahl al-Islam ('Advice to the People of Islam'), published in Fez in 1908, both of which called on Moroccans to unite against European encroachment.$^{:68,86}$

### Mass media

News media came to Morocco in 1860 through Spanish-language newspaper El Eco de Tetuan in Tetouan, which was founded shortly after the Treaty of Wad Ras. The Treaty of Madrid in 1880 allowed for the rise of two newspaper, al-Moghreb al-Aksa, printed in Spanish by G.T. Abrines, and the Times of Morocco, printed in English by Edward Meakin. Three years later, the French-language Le Réveil du Maroc was founded by Abraham Lévy-Cohen, a Moroccan Jewish businessman.
During modernization attempts for the Moroccan state under Moulay Abdelhafid to counter European influence, a draft constitution was published in the October 1908 issue of newspaper Lissan-ul-Maghreb in Tangier. The 93-article draft emphasized and codified the concepts of separation of powers, good citizenship, and human rights for the first time in the country's history.
The draft, which was written by an anonymous author and was never signed by Moulay Abdelhafid, was inspired by the late 19th century constitutions of the Ottoman Empire, Egypt, and Persia. In 2008, al-Massae claimed that the draft was written by members of a "Moroccan Association of Unity and Progress" composed of an elite close to Moulay Abdelhafid which supported the toppling of his predecessor, Abdelaziz.

### Architecture

Starting with the Saadians and continuing with the Alawis, Moroccan art and architecture is often described by art historians as being relatively conservative; meaning that it continued to reproduce the earlier Hispano-Maghrebi architectural style with high fidelity but did not introduce major new innovations.$^{:421–422}$$^{:194}$ Many of the mosques and palaces standing in Morocco today have been built or restored under the Alawi sultans at some point or another. Religious monuments that were built or rebuilt during this period include the Zawiya of Moulay Idris II in Fez, the Lalla Aouda Mosque in Meknes, and the current Ben Youssef Mosque in Marrakesh.
Moulay Isma'il (r. 1672–1727) is notable for building a vast imperial palace complex in Meknes, where the remains of his monumental structures can still be seen today. During this era, valuable architectural elements from earlier buildings built by the Saadi dynasty, such as the huge Badi Palace in Marrakesh, were also stripped and reused in buildings elsewhere during the reign of Moulay Isma'il.$^{:264–272}$ Other Alawi sultans built or expanded the royal palaces in Fez, in Marrakesh, and in Rabat.
In 1684, during Moulay Isma'il's reign, Tangier was also returned to Moroccan control and much of the city's current Islamic architecture dates from his reign or after. In 1765, Mohammed ibn Abdallah started the construction of the new port city of Essaouira through which he tried to control European trade.$^{:264}$ He hired European architects to design the city, resulting in a relatively unique Moroccan-built city with Western European architecture, particularly in the style of its fortifications. Similar coastal fortifications or bastions, usually known as a sqala, were built at the same time in other port cities like Anfa (present-day Casablanca), Rabat, Larache, and Tangier.$^{:409}$
The Alawi sultans and their ministers continued to build lavish palaces in the decades before the French protectorate. Many of these are now used as museums or tourist attractions, such as the Bahia Palace in Marrakesh, the Dar Jamaï in Meknes, and the Dar Batha in Fes.

## Economy
### Banking

The first Moroccan bank in the foreign exchange market was the Pariente Bank of Tangiers, which was founded in 1844 by Moses Pariente which cooperated with the Anglo-Egyptian Bank. In 1881, a branch of the French Banque Transatlantique was opened in Tangier by businessman Haim Benchimol.
In a debt restructuring effort, the Moroccan Debt Administration was created in 1904 which later merged in 1907 to become the State Bank of Morocco as a central bank. The State Bank of Morocco was later restructured after the end of French colonialism in Morocco and renamed to Bank Al-Maghrib in 1959 and still serves as Morocco's central bank.

### Agriculture

In pre-colonial Morocco, the predominant economic structure was centered around a rural subsistence model. Local farms were commonly held collectively, known as bled el jemâa. Established customs regulated land usage and distribution among families. Despite economic setbacks occurring periodically, civil conflicts at both national and local levels and the primitive tools employed, there remained a significant emphasis on soil exploitation and agriculture constituted the primary occupation for the majority of rural inhabitants. Numerous lands became contested territories among various groups and tribes, which sometimes prompted the Makhzen to intervene in order to settle the disputes.
Pierre Tralle, a French prisoner who also participated in the construction of Meknes over a seven-year period until 1700, highlighted in his report on the Moroccan situation the fertility of the land which he considered to be adapted to producing high-quality crops.
Despite opening to trade in the late 19th century, Morocco faced limitations due to inadequate agricultural surplus and the antiquated transportation system, which hindered commercial activities. Foreign land ownership was largely unattainable before colonization, even though European powers secured legal exceptions allowing land speculation around major harbors through treaties such as the Treaty of Madrid in 1880 and the Treaty of Algeciras in 1906.
During the latter half of the 19th century, there was an increased interest on irrigation and agricultural activities, particularly under the reign of Mohammed IV, sparked when he was still the caliph of Marrakech. This interest lead to the creation of various water sources in the region, and the construction of a canal originating from Wadi N'Fiss [fr], as well as another canal named Fitout River which transported water from Tastaout to the plains encompassing Zemrane, Rahamna, and Sraghna. Throughout the 19th century, the Chaouia region rose as an important grain and livestock exporting hub through the port of Anfa, despite governmental policies restricting exports.
An important shift in the types crops cultivated was observed in many regions prior to the establishment of the protectorate. The cultivation of olive trees, once prevalent across the coastal plains along the Atlantic coastal regions and the Rif, significantly declined.
The Atlantic plains were renowned for the quality of their wheat, barley, and abundant vineyards, while vegetable cultivation was primarily concentrated near urban centers. Morocco also produced oranges, almonds, walnuts and figs. The introduction of new crops, such as aloe vera from the Americas, and potatoes from Europe, affected agriculture in Morocco. During the 19th century, the cultivation of plants like henna, flax, hashish, and turmeric gained prominence. Forested areas retained their original situation and composition, comprising oak and argan trees, and other species like willows, junipers, and pines.

### Taxation

During Moulay Ismail's reign, the sultanate's revenues primarily derived from taxes, with the two main sources being the Ashur and the Ghrama. The Ashur was collected in kind, constituting one-tenth of all agricultural produce, while the Ghrama was paid in cash according to individuals' wealth. The governors determined the amount of these taxes based on their knowledge of the population and the state of harvests.

### Coinage

The Alawis did not initiate the development of a new national currency until 1668, instead allowing local currencies to circulate for an extended period. In 1668, Moulay Rashid decided to introduce a new silver currency called mouzouna that consisted of 20% copper with the ultimate goal of boosting regional trade. Previous Saadi and Dilaid gold currencies continued to circulate until the reign of Moulay Ismail, who decided to emit a new gold dinar called bunduqi.

## Aftermath: colonial rule and independence

Under colonial rule, the institution of the sultan was formally preserved as part of a French policy of indirect rule, or at least the appearance of indirect rule. Under the French Protectorate, the 'Alawi sultans still had some prerogatives such as the power to sign or veto dahirs (decrees). In the Spanish zone, a Khalifa ("deputy") was appointed who acted as a representative of the sultan. In practice, however, the sultan was a puppet of the new regime and many parts of the population saw the dynasty as collaborators with the French. The French colonial administration was headed by the French resident-general, the first of whom was Hubert Lyautey, who enacted many of the policies that set the tone for France's colonial regime in Morocco.
Eventually, with the decolonialization process in Tunisia, the independence war in Algeria, and the rise of the Moroccan Army of Liberation all taking place during the 1950s, the French agreed to negotiate Morocco's independence at a conference on August 23, 1955. The exiled Alawi sultan, Mohammed V, landed at Rabat-Salé Airport at 11:42 am on November 16. The French-Moroccan Declaration of Independence was formally signed on March 2, 1956, and Tangier was reintegrated to Morocco later that year. In 1957 Mohammed V adopted the official title of "King", which has since been used by his successors, Hassan II and Mohammed VI.