Moroccan Jews constitute an ancient community. Before the founding of the State of Israel in 1948, there were about 265,000 Jews in the country, which gave Morocco the largest Jewish community in the Muslim world, but by 2017 only 2,000 or so remain. Jews in Morocco, originally speakers of Berber languages, Judeo-Moroccan Arabic or Judaeo-Spanish, were the first in the country to adopt the French language in the mid-19th century, and unlike the Muslim population French remains the main (and, in many cases, the exclusive) language of members of the Jewish community there.
It is possible that some Jews fled to North Africa after the destruction of the First Temple in the sixth century BCE or the destruction of the Second Temple in the first century CE. It is also possible that they arrived on Phoenician boats (1500 BCE - 539 BCE).
Based on the writings of Ibn Khaldun, an Arab scholar of the 8th century CE, some suggested that Moroccan Jews were indigenous Imazighen (Berbers) who converted to Judaism, although the question of who converted them remains. This theory has been rejected by most scholars. It was also refuted by modern genetic studies, which revealed that North African Jews are genetically close to European Jews and do not share haplogroups typical of the North African Berber and Arab populations. According to one study, "North African Jews date to biblical-era Israel, and are not largely the descendants of natives who converted to Judaism".
The Jewish community of Ifran, from the Tamazight word ifri meaning cavern, is supposed to date back to 361 BCE and is believed to be the oldest Jewish community in what is now Morocco.
The first irrefutable evidence of Jews in what is now Morocco, in the form of gravestone epitaphs in Hebrew at Volubilis and the ruins of a third century synagogue, dates back to late antiquity. Emily Gottreich contends that Jewish migration to Morocco predates the full formation of Judaism, as the Talmud was "written and redacted between 200 and 500 CE.