Safi’s natural harbour was known to the Phoenicians and the Romans, and in the 11th century, it was a port for the trans-Saharan trade between Marrakesh and Guinea, where gold, slaves and ivory were sold. In the 14th century, the town became an important religious and cultural centre when the Merenids built a ribat here. The Portuguese took the city for a brief spell from 1508 until 1541, when the Saadians took it back. They built the monumental Qasr Al Bahr fortress and generally expanded the town, but destroyed most monuments upon their departure.
In the 16th century, Safi grew wealthy from the trade in copper and sugar, and European merchants and agents flocked to the city, but when the port at Essaouira was rebuilt in the 18th century Safi was largely forgotten.
Safi’s real revival came in the 20th century when its fishing fleet expanded and huge industrial complexes were built to process the 30,000 tonnes of sardines caught annually. A major phosphate-processing complex was established south of the town and the city began to expand rapidly. Today, Safi is one of Morocco’s largest ports.