A mellah  is a walled Jewish quarter of a city in Morocco,  analogous to the European ghetto.  Jewish population were confined to mellahs in Morocco beginning from the 15th century and especially since the early 19th century. It first was seen as a privilege and a protection against the Arabs’ attacks in the region, but with the growing of the population, it then became a poor and miserable place.

In cities, a mellah was surrounded by a wall with a fortified gateway. Usually, the Jewish quarter was situated near the royal palace or the residence of the governor, in order to protect its inhabitants from recurring riots due to its inhabitants playing a vital role in the local economy. In contrast, rural mellahs were separate villages inhabited solely by the Jews.

The mellah is now one of the poorest neighborhoods in Essaouira, located within the walls in the northern part of the medina.  Jews came to Essaouira for the wealth of the port and the trade opportunities it offered,  taking advantage of attractive incentives to handle the trade with Europe by Mohammed 111 in the 18th century.  Jews once comprised 40% of the population, and the mellah contains many old synagogues.  The city flourished until the caravan trade died, supplanted by direct European trade with sub-Saharan Africa.