Later in the fourteenth century, the city twice fell under the rule of the Marinid sultan, Abu al-Hasan Ali (1337–48) and his son Abu 'Inan. Both times the Marinids found that they were unable to hold the region against local resistance. Nevertheless, these episodes appear to have marked the beginning of the end. Over the following two centuries, Zayyanid Tlemcen was intermittently a vassal of Ifriqiya (then governed by the Hafsid dynasty), Maghrib al-Aksa (then governed by the Marinid dynasty), or the Aragon. When the Spanish took the city of Oran from the kingdom in 1509, continuous pressure from the Berbers prompted the Spanish to attempt a counterattack against the city of Tlemcen (1543), which the papacy deemed a crusade. The Spanish failed to take the city in the first attack, although the strategic vulnerability of Tlemcen caused the kingdom's weight to shift toward the safer and more heavily fortified corsair base at Algiers.