The ups and downs of Safi's history are closely linked to its port vocation.
Phoenician counter, according to the geographer Ptolemy, probably frequented by the Romans later, the name Asfi appears in Arabic writings from the XNUMXth century.
With Safi Hadirat al Mouhit or City of the surrounding sea, according to Ibn Khaldoun's expression, Safi ensured, as the port of the capital Marrakech of the Almohad empire in the XNUMXth century, direct relations with Andalusia and presented in the form of a highly urbanized space, endowed in particular with important fortifications and a large central mosque.
Made up of two urban entities, the city was enriched, in the 15th century, by a medersa, built by Aboul Hassan Al Marini, a bimaristan (hospital) and many other institutions, a qaysaria, a mohtasseb, as and as Safi established itself as a place of important exchanges that traded with Genoa, Seville and Marseille. In the XNUMXth century, Safi opened up to European trade.