On the eve of the independence of Morocco in 1956, there were hundreds of Jewish communities throughout the country, representing a total population of about 280,000 people, the largest Jewish community in the Muslim world.

Many of these communities had been in existence for several centuries, and the origins of some date back to antiquity. It is generally agreed that Jews arrived with Phoenician traders hundreds of years before the Christian era. The two peoples lived together in some of the coastal settlements that are today known as Tangier, Rabat and Essaouira.

Jews were clearly part of the Roman cities that developed in the first century. Many of them moved into Morocco by migrating westward along the Mediterranean coast from the large Jewish centre in Carthage (Tunisia). Traces of Jewish life can be found in Volubilis, the large excavated city near Meknes.

Other Jews moved inland from Cyrenaica (Libya), converted Berber tribes, and established settlements in the foothills, mountains and desert oases of Algeria and Morocco.

By the year 732, the conquering Arab armies had established an empire extending to Morocco and Spain. Idriss I founded the first Muslim state in Morocco in the late eighth century. His authority extended over central and western Morocco, and he fought against those Christians and Jews who would not convert. Following his victory, most Jews moved into the mountain and desert areas that were not controlled by Idriss.

His son, Idriss II, created the city of Fez in the early ninth century, developing it from a village that is believed to have been inhabited by a Jewish tribe. He invited Jews to live there together with Arabs. While he restricted the freedom of the Jewish community in accordance with Islamic law, he also created the economic conditions that allowed some Jews to become prosperous.

A Berber tribe from the Sahara desert, the Almoravides, created an Islamic empire in Morocco and Spain in the eleventh and twelfth centuries. They founded their capital of Marrakesh near Aghmat, a Berber Jewish settlement. Although Jews were not allowed to enter Marrakesh at night, they had sufficient freedom to move throughout Morocco and Spanish Andalucia. Jewish scholars migrated to the Almoravide empire, producing some of the religious writings associated with the "Golden Age" of the Jews.

In the twelfth century, the Almohads, a Berber mountain people, developed a fundamentalist Islamic doctrine and built an empire that spread from Spain to western Libya. Unlike the Almoravides, they did not take the Jews under their protection. Instead, they expelled them from Marrakesh and tried to eliminate their presence from Morocco. Under the Almohad leader Abdel Moumen, the Jews were persecuted to the point that their communities in the oasis communities of the Draa and Sijilmassa were destroyed. Jews in these communities who did not convert were killed. During this time, Maimonides left Cordoba and spent several years in Morocco. From 1159-1165, he lived in the old city of Fez. Persecution of Jews was so intense that Maimonides counseled all Jews to leave the country. By 1224, there may have been no synagogue left in Morocco.

The Almohads were overthrown in the mid-thirteenth century by the Merenids, who gave preferential treatment to the Jews. Resentment of the Sultan and his close ties to the Jews incited a pogrom in Fez in 1276. The Merenids then established Fez-Jdid (New Fez) as their capital, where Sultans could provide the nearby Jews with greater security. During the 14th century, when the Merenids had relatively firm control of Morocco, Jews and Muslims coexisted with few problems. By 1438, the Merenids could not easily control the country or protect Jews living in urban areas. In Fez-Jdid, they forced the Jews to move into a fortified area adjoining the royal palace, to ensure their safety. This was the first Jewish quarter in Morocco. Because it was built on an old salt mine, this and all subsequently constructed Moroccan Jewish quarters were called mellahs, based on the Arabic word for salt.

The Merenids lost power to the Wattasids, a weak dynasty that ruled for eighty years beginning in 1472. The Watassids were unable to prevent the Portuguese from establishing forts and trading posts in towns all along the Atlantic coast. The Wattasids neither encouraged nor prevented tens of thousands of Jewish refugees from Spain and Portugal from entering Morocco in the late fifteenth and early sixteenth centuries. Queen Isabella of Spain had issued the Edict of Expulsion on March 31, 1492, three months after the fall of Muslim Grenada. The edict gave four months for the 165,000 Spanish Jews to either convert or leave the country. Although many of them entered Morocco, only about 20,000 made the country their new home, while the rest continued on to the Ottoman Empire.

The Saadian dynasty, which took over in the 16th and 17th centuries, suffered from political instability and military attacks throughout its reign. To finance military activities, Saadian Sultans taxed the Jewish community heavily. To ensure that the Jews had adequate resources to pay these taxes, Sultans gave Jewish traders the monopoly over sugar exports. These traders were also responsible for a large percentage of the imports of European cloth and guns. Jews played a key role in the caravan trade with Sub-Saharan Africa, financing the exchanges of European cloth and Moroccan cereals for gold, ostrich feathers, gum arabic, and ivory.

Under the Saadians, Spanish and Portuguese Marranos moved to Morocco's coastal cities, where they could work for the Portuguese traders and reconvert to Judaism. In 1578, the Saadians defeated the Portuguese in a famous battle near Ksar el Kabir, a coastal settlement near Tangier. Since three kings died in the battle, some Moroccan Jewish communities established a special Purim holiday, the Purim of the Three Kings, that was celebrated until recently.

The currently ruling Alaouite dynasty is a family of Arabs descended from the Prophet Mohammed. The first Alaouite ruler, Moulay Rachid, came from the southeast oasis of Tafilalet and took power from the Saadians in the 1660's. Through capturing the caravan routes in eastern and western Morocco, Moulay Rachid was able to ensure the cooperation of Jewish traders in financing the new empire.

Moulay Ishmael succeeded Moulay Rachid in 1672 and completed the task of pacifying Morocco. He constructed his capital in the city of Meknes. During his 55 year reign, Jews were protected from violence, although they were taxed highly. In 1679, he forced the Jews to construct the Meknes mellah. Meknes attracted Jewish immigrants from throughout Morocco, and the mellah was relatively prosperous in the beginning of the 18th century. Elsewhere in the country, Jewish traders grew wealthy from increased trade with Europe and within Morocco.

After the death of Moulay Ishmael, Morocco fell into 30 years of anarchy. By the 1760's, Moulay Mohammed was able to create some political stability. The Sultan increased the economic and political importance of the Jews through populating coastal cities with Jewish traders. He installed Jews in the Portuguese city of Mazagan (El Jadida) and created the port of Mogador (Essaouira). He declared that all trade was to go through Mogador, so that he could better control customs revenues. The Sultan asked wealthy Jewish families throughout the country to send family members to become traders in Mogador, where they received special financial treatment. Islamic law was applied liberally in Mogador, enabling Mogadorian Jews to be the first Moroccan Jews to dress in Western clothing.

When Moulay Mohammed died, his son, Moulay Yazid, succeeded him. Moulay Yazid had an intense hatred for the Jews and incited pogroms throughout the country between 1790 and 1792. He encouraged attacks on the mellahs of Tetouan and other cities. The worst treatment was reserved for Meknes and Fez. The Jews of Fez were forced to leave the mellah for two years. Marrakesh Jews also received an expulsion order, and their mellah was pillaged.

Succeeding Sultans allowed Jews to rebuild their homes, businesses and synagogues, although not outside the mellahs. While Jewish life in Morocco flourished in the early nineteenth century, the ability of the Sultans to control the country deteriorated. In several geographic regions, Muslim fraternities and traditional tribal leaders had greater political support than the Sultan. European powers attempted to impose their authority, particularly with respect to trade. As a result, Moroccan Sultans were not always able to protect the security of the Jews.

With European encouragement, Sultan Sidi Mohammed issued a royal decree in February 1864, affirming that the Jews would be treated as equals under the law, with justice and impartiality, and that anyone mistreating them would be prosecuted.

The efforts of European powers to push the Sultan's government into bankruptcy coincided with criticisms by non-Moroccan Jewish organizations of the treatment of Moroccan Jews. In 1905, the US Government sent an investigatory mission to Tangier to determine the validity of claims that Moroccan Jews were being oppressed. The researchers found that the dhimmi regulations had not been implemented since the 1870's. The head rabbi of Tangier asked the Americans not to intervene on behalf of the Moroccan Jews. At the 1906 Algeciras Conference, the U.S. representatives ensured that the conference documents praised the Sultan's government for improvements in conditions of Jews and asked it to guarantee to treat all Moroccans equally.

In 1907, the French found a pretext for full-scale invasion of Morocco when a few Europeans in Marrakesh and Casablanca were killed. After 3,000 French troops occupied Casablanca, the mellah was pillaged.

From 1907-1912, French and Spanish soldiers took control of increasingly large areas of the country. The French gained effective control over Morocco with the signing of the Treaty of Fez in 1912, establishing the majority of Morocco as a French protectorate. Spain was given control of Northwest Morocco and in 1923 the city of Tangier became an international zone.

In August 1941, the Vichy Government of France enacted laws that discriminated against Moroccan Jews. It set quotas on the number of Jewish doctors and lawyers, ejected students from French schools and forced many Jews living in the European quarters to move to the mellahs.

The Moroccan Sultan, Mohammed V, told Jewish leaders that in his opinion Vichy laws singling out the Jews were inconsistent with Moroccan law. He believed that Jews should be treated equally with Muslims. He emphasized that the property and lives of the Jews remained under his protection. Due to his strong stance, Vichy administrators did not implement the discriminatory laws and regulations energetically.

Following the arrival of American troops in November 1942, the French closed off several mellahs and the Vichy laws were eventually repealed.

In response to anti-Jewish rhetoric in the wake of the creation of the State of Israel and the eruption of the Arab-Israeli conflict, Sultan Mohammed V warned Muslims not to hurt Moroccan Jews, reminding them that Jews had always been protected in Morocco and had always showed their devotion to the Throne. He emphasized that Jews were well-treated Moroccan subjects with the obligation to support the Sultan, and he voiced support for other Arab leaders. The speech was read in all synagogues.

Tensions associated with the Israeli-Arab War and the beginnings of Moroccan Jewish emigration to Israel contributed to two pogroms in the eastern towns of Oujda and Djerrada in June 1948. The pogroms, which were not well controlled by the French authorities, resulted in 8 deaths, 600 wounded and 900 homeless in the Jewish community of Oujda. In Djerrada, there were 39 dead and 44 wounded. The Pacha of Oujda expressed his regrets about these incidents and met with each victim's family.

Between the creation of Israel in 1948 and Morocco's independence in 1956, 90% of Moroccan Jews left the country. The poorest settled in Israel, where they constitute a significant part of the working class, while the elite and middle class emigrated to Canada and France.

If the Jewish community numbered several hundreds of thousands of people until the twentieth century, fewer than 7,000 now remain in the country. The bulk of this community is concentrated in Casablanca and Rabat. Essaouira (Mogador), a city where the number of Jewish residents exceeded 60% not so long ago, and the traditional communities of Fez, Meknes or Marrakesh have lost their people and their dynamic culture. The various Jewish communities of Moroccan origin worldwide now have a combined population of over a million Jews.