The Marinids had been fighting the Almohads for supremacy over Morocco since the 1210s. At the time of Abu Yahya's death in July, 1258, the Marinids were installed in Fez and controlled eastern and northern Morocco, the Almohads reduced to the southerly districts around their capital, Marrakech. Although Abu Yahya had designated his son as successor in Fez, Abu Yusuf Yaqub, then a governor in Taza, managed, with only a little difficulty, to displace his nephew and get himself acknowledged as emir of the Marinids.
In September, 1260, in a surprise attack, a Christian naval force from Spain, probably Castilian, landed on the Atlantic coast of Morocco and seized the city of Salé. Abu Yusuf retook the city after a fourteen-day siege. It was the first known direct encounter between the Marinids and the Christian powers of the Iberian peninsula. Abu Yusuf decided against a retaliatory raid, and instead focused on reducing the Almohad resistance in the south.
In 1262, Abu Yusuf laid siege to the Almohad capital of Marrakech, but his attempt to assault the city faltered. Changing tactics, he decided to sponsor the rebellious Almohad chieftain Abu Dabbus in his struggle against his cousin, the Almohad caliph Abu Hafs Umar al-Murtada. But once Abu Dabbus seized Marrakech in 1266, he broke his treaty with the Marinids and refused to pass Marrakech over to them. Instead, Abu Dabbus persuaded the Abdalwadid ruler Yaghmorassan of the Kingdom of Tlemcen to launch an incursion into Marinid land from the northeast. Abu Yusuf broke off his campaign against the errant Almohad client to deal with the Tlemcen intervention, defeating the Abdalwadids at a battle by the Moulouya in 1268.
Abu Yusuf promptly returned to the south, defeated the forces of Abu Dabbus and entered Marrakech on 8 September 1269, putting a final end to the Almohad Caliphate. The Marinids were masters of Morocco, and Abu Yusuf Yaqub took up the title of 'Prince of the Muslims' (amir el-moslimin), the old title used by the Almoravid rulers in the 11th-12th centuries. Like the Almoravids, the Marinids never adopted the caliphal title (amir al-mu'minin), believing it to be an impious pretension (although the contemporary Hafsid rulers of Ifriqiya would soon take it up).
The Marinids resisted the temptation of relocating their capital to the Marrakech, citadel of the Almoravids and Almohads, preferring to base themselves at Fes.
The Marinids had some difficulty getting their authority recognized by the southerly Ma'qil Arabs of the Draa valley and Sijilmassa. The Draa valley Arabs submitted only after a campaign in 1271, and Sijilmassa only in 1274. The northerly port cities of Ceuta and Tangiers also refrained from acknowledging Marinid suzerainty until 1273.
Part of this resistance had been encouraged by Abdalwadid ruler Yaghmorassan of Tlemcen, and so in 1272, Abu Yusuf launched a punitive expedition and even briefly laid siege to Tlemcen, forcing the Abdalwadids to come to terms. Abu Yusuf erected the advanced coastal fortress of Taount to police any future Abdalwadid interventions in Marinid dominions.
Ibn Khaldoun's account of Abu Yusuf's 1274 siege of Sijilmassa relates what seems to be one of the first uses of powder cannon as a siege weapon.
In 1272, the Nasrid ruler Muhammad I of Granada had appealed to the Marinid emir Abu Yusuf Yaqub for assistance. Granada was then plunged in civil war, with the Nasrids fighting off a challenge from the rival Banu Ashqilula family, rulers in Málaga, Guadix and Comares. The Christian king Alfonso X of Castile had thrown his weight behind the Ashqilula - in part because the Nasrids themselves had sheltered Castilian rebels. But the Marinid emir Abu Yusuf was then engaged against Tlemcen and could not intervene.
In 1274, Muhammad I's son and successor, Muhammad II al-Faqih struck a deal with Alfonso X, paying the Castilian king some 300,000 maravedis and promising not to intrigue with Castilian rebels. But Alfonso X did not fulfill his side of the agreement and continued his support for the Ashqilula, so Muhammad II renewed his request to the Marinids for assistance, offering them the Iberian towns of Tarifa, Algericas and Ronda as payment.
With Morocco now pacified and Tlemcen controlled, in April, 1275, Abu Yusuf Yaqub took up the Nasrid request and crossed the straits, landing a large Moroccan army in Spain. The Marinids quickly took Tarifa and Algeciras and confirmed their pact with Muhammad II. The arrival of the Marinids and the absence of Alfonso X (then at a meeting with the pope in France) prompted the Banu Ashqilula to quickly come terms with the Nasrids. With that out of the way, raids were launched on Castilian lands - the Marinids ravaged Castilian-ruled Andalusia below the Guadalquivir, while Muhammad II led a Granadan army against Cordoba.
News of the Marinid landing had prompted frantic preparations by the Castilian crown prince Ferdinand de la Cerda, left regent in his father's absence, to counter it. But the prince fell sick and died in July, an event that would soon plunge Castile into a crisis of succession.
The Marinid emir Abu Yusuf defeated a large Castilian army under Nuño González de Lara "el Bueno", adelantado de la frontera, in the pitched Battle of Écija in September. A second army led by the Archbishop Sancho II of Toledo in October met a similar fate. Only the rapid rallying of Castilian forces by infante Sancho kept the Marinids from doing more damage. Alfonso X arrived back in Castile at the end of the year and negotiated a truce with Abu Yusuf Yaqub.
Returning to Morocco in early 1276, flush from his successes over Tlemcen and Castile, the Marinid emir Abu Yusuf was greeted by news that the Marinid governor of Marrakech had finally reduced the last remnants of the Almohad dynasty in Tinmel. It seemed an appropriate time to erect a splendid new city to serve as the capital of a new dynasty.
In March, 1276, Abu Yusuf Yaqub laid down the plans and initiated the construction of El-Medinat el-Beida ('White City'), what will later become known as Fes el-Jedid ('Fez the New'), across the river from the old Idrisid city of Fez (now known as Fez el-Bali ('Fez the Old')). Fes el-Jedid will serve as the Marinid capital throughout.
In August 1277, Abu Yusuf Yaqub crossed the straits again with a Moroccan army. This time he moved further north, ravaging the districts of Jerez, Seville and Cordoba.
In 1278, in a remarkable turn-around, the Marinid ruler struck a deal with the Banu Ashqilula, rivals of the Nasrids of Granada, whereby the Ashqilula ceded their city of Málaga to the Marinids, in return for Marinid protection. News of the deal infuriated the Nasrid ruler Muhammad II al-Faqih of Granada, who promptly sought out the support of Alfonso X of Castile and the Abdalwadid ruler Yaghmorassan of Tlemcen to punish the Marinids.
In early 1279, while the Abdalwadids launched a diversionary raid on Morocco, the Castilians dispatched a fleet to blockade the straits. Muhammad II led a Granadan army upon Málaga, which soon fell in a negotiated settlement. In a new treaty, Marinid emir Abu Yusuf agreed to surrender his claims on Málaga and withdraw his protection of the Ashqilula, in return for which Muhammad II handed over Almunecar and Salobrena to the Marinids.
No sooner was this done, that the attention of the Muslim parties turned towards Marinid Algeciras which Alfonso X had decided to take for himself. Anxious not to let it fall in Christian hands, Muhammad II lent his own ships to join the Marinid fleet under the command of the Abu Yusuf's son, Abu Yaqub. The Marinids defeated the Castilians at the Battle of Algeciras on 21 July 1279, and forced Alfonso X to lift the siege and withdraw.
But no sooner had the Castilian threat receded, that Abu Yusuf and Muhammad II fell into a quarrel over whom exactly held suzerain title over Algeciras and Málaga. Now it was the turn of the Marinids to forge an alliance with Alfonso X of Castile. The Marinids supported Castilian raids against Granada in 1280 and 1281. For his part, Muhammad II al-Faqih of Granada turned to Peter III of Aragon and Alfonso X's estranged son, the infante Sancho. The Abdalwadid ruler Yaghmorassan of Tlemcen was happy enough to align with the Granadan-Aragonese, and was promptly punished by a new Marinid campaign against Tlemcen in 1281.
In April, 1282, the political crisis in Castile reached its apex when the infante Sancho quarreled with his father and, with the support of the bulk of the Castilian nobility, declared himself King Sancho IV of Castile. His father, Alfonso X fled to Seville, his support reduced to the Muslim-heavy districts of Andalusia and Murcia. With Muhammad II of Granada in league with Sancho, Alfonso X appealed to the Marinids of Morocco for support.
At Alfonso X's request, Abu Yusuf crossed the straits for the third time in July, 1282. A pact was forged with Alfonso X in October, and a joint Alfonsine-Marinid army marched against Sancho IV in Córdoba. But Sancho IV was to well-entrenched to dislodge. Nothing much came of this campaign, and the Marinids returned to Morocco soon after, with little to show for their efforts.
The ever-troublesome Abdalwadid ruler Yaghmorassan of Tlemcen died in the Spring of 1283, and his successor, Abu Said Othman, immediately sought to mend relations with the Marinid emir Abu Yusuf, thus temporarily relieving a persistent source of stress.
Alfonso X died in April 1284, throwing Castile into a new crisis by designating his grandson Alfonso de la Cerda, rather than Sancho IV as his heir. With his back freed from the Tlemcen threat, Marinid emir Abu Yusuf decided to honor Alfonso X's choice with a new expedition to Spain to support Cerda and his confederates. In Granada, the Banu Ashqilula, under a renewed Nasrid assault, had also appealed to the Marinids.
But all this had to be postponed, as Abu Yusuf had to spend much of 1284 putting down a Maqil rebellion in the Draa valley.
Finally, in April 1285, Marinid emir Abu Yusuf Yaqub crossed the straits for the fourth (and last) time. Although Comares had fallen to the Nasrids of Granada, the Marinids managed to rescue Guadix, the last Ashqilula stronghold. As the bulk of the Moroccan army landed in Tarifa, Abu Yusuf promptly led them into Andalusia to lay siege to Jerez. Moroccan detachments were dispatched to devastate a broad area from Medina Sidonia to Carmona, Ecija and Seville. Nervous at Seville's disposition (a Cerda party stronghold), Sancho IV assembled his army there, and dispatched the Castilian fleet, some hundred ships under his Genoese admiral Benedetto Zaccaria, to blockade the mouth of the Guadalquivir, and prevent the Marinid navy from assaulting Seville upriver.
In August, 1285 Sancho IV was finally ready to march the Castilian army against the Moroccans at Jerez. Finding a pitched battle unwise, Abu Yusuf decided to lift the siege of Jerez, withdrew his army to the safety of Algericas, and opened negotiations with the Castilian usurper.
In October 1285, Sancho IV of Castile secured a five-year truce and treaty with the Marinid emir Abu Yusuf. In return for promises not to intervene in Castile for the Cerda party, the Marinids received equal assurance that there would be no more Castilian lunges on Muslim territories in Spain (whether Marinid or Nasrid). To seal the deal, Sancho IV agreed to hand over to the Marinids the collection of Arabic books that had been seized from Andalusian libraries by Church authorities during the Reconquista, in return for Marinid payment of cash compensation for the Castilian property taken and damaged by the marauding Moroccan armies.
In March, 1286, Abu Yusuf also began negotiating a final settlement with the Granadan ruler Muhammad II. The Granadans agreed to recognize Marinid possession of Tarifa, Algeciras, Ronda and Guadix, in return for which the Marinids agreed to surrender all other possessions and claims on any other towns or dominions on the Iberian peninsula. The remnants of the Banu Ashqilula family would be exiled to Morocco, and the Marinids would guarantee they would cease all intrigues against the Nasrid rulers.
Abu Yusuf Yaq'ub was in the middle of these negotiations, when he fell ill and died on 21 March 1286 in Algeciras. Abu Yusuf's remains were translated to the Marinid necropolis at Chellah which had himself built. He was succeeded by his son, Marinid emir Abu Yaqub Yusuf of Morocco.
While it is common to designate Abd al-Haqq or Abu Yahya as the founders of the Marinid dynasty, there is little doubt that Abu Yusuf Yaqub ought to be rightly regarded as the founder of the Marinid state. He put a final end to the Almohads, unified Morocco, established their new grandiose capital at Fez el-Jedid and gave the Marinids their foothold in Spain.
However, he also left it in a fragile state. The Arabs and Maqil of the south remained only half-subdued, the Sanhaja of the High Atlas unconvinced, and, to the east, Tlemcen remained an unbowed and unbroken threat.
Abu Yusuf Yaqub may have turned the Marinids into the pre-eminent Muslim power of the region - certainly stronger than the Nasrids of Granada, the Abdalwadid of Tlemcen or the Hafsids of Ifriqiya. But they remained, at root, a tribal dynasty, and without the kind of religious authority or prestige the Almoravids or the Almohads enjoyed, the Marinid chances of replicating their empires over the Maghreb and Spain were fatally circumscribed.