The Kasbah was constructed by Mulay Alí Ben Rachid
and soon recovered by Mulay Ismail at the end of 17th century
to defend the city. First of all the Portuguese tried to attack
the city then later the rebellious tribes Bereberes and after
that the Spaniards tried to attack.
The city was closed to all the foreigners, specially to the
Christians, until the beginning of the Spanish occupation