The greatest threat to Almohad rule in Tunisia was the Banu Ghaniya, relatives of the Almoravids, who from their base in Mallorca tried to restore Almoravid rule over the Maghreb. Around 1200 they succeeded in extending their rule over the whole of Tunisia until they were crushed by Almohad troops in 1207. After this success, the Almohads installed Walid Abu Hafs as the governor of Tunisia. Tunisia remained part of the Almohad state, until 1230 when the son of Abu Hafs declared himself independent. During the reign of the Hafsid dynasty, fruitful commercial relationships were established with several Christian Mediterranean states. In the late 16th century the coast became a pirate stronghold.