In 1506, the king of Portugal, D. Manuel I ordered a fortress to be built there, named "Castelo Real de Mogador". Altogether, the Portuguese are documented to have seized 6 Moroccan towns, and built 6 stand-alone fortresses on the Moroccan Atlantic coast, between the river Loukos in the north and the river of Sous in the south. Four of them only had a short duration: Graciosa (1489), Sao Joao da Mamora (1515), Castelo Real of Mogador (1506–10) and Aguz (1520–25). Two of them were to become permanent urban settlements: Santa Cruz do Cabo de Gué (modern Agadir, founded in 1505-06), and Mazagan founded in 1514-17. The Portuguese had to abandon most of their settlements between 1541 and 1550, although they were able to keep Ceuta, Tangier and Mazagan. The fortress of Castelo Real of Mogador fell to the local resistance of the Regraga fraternity four years later, in 1510.
Source: Wikipedia - Essaouira