Serge Berdugo (article below) is right. Yes, Morocco welcomed the Jews fleeing the Spanish Inquisition. Yes, Jews and Muslims coexisted and still do. Yes, the king of Morocco is a unifying figure. King Mohammed V tried to protect the country's Jews and some even claim that during the war years stepped in to prevent their deportation.
But Berdugo - understandably - omits to mention the rather vital fact that Jews and Muslims coexisted within the constraints of dhimmitude -that is to say, on unequal terms. Until Morocco became a French protectorate in 1912, the Jews had limited legal rights. They were confined to the mellah; they could not own property. They were periodically massacred (According to Wikipedia, 400 were killed in Tetuan in 1859)and subject to forced conversion.
In his book Histoire des juifs d'Afrique du Nord, Andre Chouraqui (pps 170 - 172) gives a convincing explanation for their exodus. When the French finally departed, granting Morocco independence in 1956, the Jews, no longer shielded by the French colonial class, were exposed as Le petit blanc (the Little White Man). Only the rich and the 'technicians' could survive. The mass of poor Jews were resented by the great mass of even poorer Arabs who subsisted on a yearly income of less than $50. The Jews understood that they would be crushed under this irresistible social pressure and fall to the bottom of the pyramid.
Bu the proximate cause of their departure was a hardening of attitudes towards the Jews. Almost as soon as Morocco became independent Mohammed V played off political parties against each other and kow-towed to the Arab League. When the leftwing of the Istiqlal party rose to power the Jews were thrown into a panic. The Jews became the scapegoats of choice. Adopting anti-Jewish and anti-Zionist measures to please the Arab league, postal links between Morocco and Israel were cut. The ephemeral Jewish postal minister ceased to exist. Certain senior Jewish civil servants found themselves in disgrace and a numerus clausus (quota) was introduced for Jews in public service. Jews were refused passports, forcing them to emigrate illegally.
Things got worse after the Arab League meeting in Casablanca in 1959. The police set out in hot pursuit of those Jews who wished to leave Morocco. All escape routes were blocked. Those Jews who were caught trying to escape were thrown into jail and tried for 'jeopardising state security'. And so Zionism became a crime. A Jewish notable in Meknes was brought to court for owning a Keren Kayemet (Jewish National Fund) calendar. Another was arrested and beaten for wearing a blue and white kippa while praying in synagogue. All charitable and social institutions were suspected of Zionism.
The director-general of ORT - Maroc (an organisation for vocational training) was arrested by the police, put on a plane and expelled. A newspaper published an article about the 'Zionist hydra' while Nasser was welcomed in triumph in Casablanca.
The Pisces episode was the saddest and most dramatic in this unequal fight between the Moroccan administration and the Jews: 40 clandestine Jewish emigrants were drowned when their ship sank in a storm between Tangiers and Gibraltar. The King had allowed this absurd policy, which flew in the face of Moroccan honour and tradition, to continue. He died on 26 February 1961.
His successor Hassan II, more western in outlook and less political, allowed the Jews to leave.
The exodus of Moroccan and Tunisian Jews extended over a long period, beginning in 1947 -8 following the creation of Israel, dipping in 1953 when Israel was in the grip of a serious economic crisis, peaking in 1956 - 7 when Tunisia and Morocco became independent. Emigration was officially banned between 1958 and 1960 but took place illegally and at great risk. In 1961 and 1962, 70 percent of Jews left when the ban was lifted. The remaining Jews left after the Six Day War. Only some 3,000 remain.