The first territory Ibn Battuta crossed on his journey was, obviously, his homeland. So that’s where our journey has to begin as well.
Actually, we should probably start in an even more basic place than that, with a little etymology. Sorry. The thing is that my use of the name “Morocco,” which helps my English-speaking brain situate Ibn Battuta’s homeland geographically, is kind of problematic. Historically, for Arabic speakers, this region–at the far western edge of North Africa–is the Maghrib or, as you’ll sometimes see in modern usage, “Maghreb.” The word simply means “western place” so its usage here should be fairly self-explanatory. The modern nation is usually called al-Maghrib in Arabic, though its full name is al-Mamlakah al-Maghribiyyah, “the Western Kingdom.” The name “Morocco” derives from the city of Marrakesh, whose name may be Tamazight (Berber) in origin but we can’t be sure. In European usage for centuries Morocco was known as the “Kingdom of Marrakesh” since Marrakesh was often its capital and most important city. Morocco is still called “Marrakesh” today in Persian and several Persian-influenced languages (Pashto, Urdu, Uzbek, Sindhi, Azerbaijani, etc.)
Turks, by the way, call the country Fas, after the city of Fez. Same idea as Morocco/Marrakesh but different city. It’s a land of contrasts.
So bear all that in mind when I refer to this place as “Morocco” just because that’s easier for me and I’m lazy like that, and when I use the word “Maghrib” I’ll be referring to a larger area that also includes modern Algeria, Tunisia, and Libya. Basically all of North Africa west of Egypt. Also bear in mind that talking about distinct nations in the 14th century can be a little dicey since states and borders weren’t as well fixed as they are today. Also also, bear in mind that in referring to “Morocco” I’ll be talking about all the lands claimed by the Marinid dynasty, which was the controlling power there during Ibn Battuta’s life. That will include part of the modern disputed territory of Western Sahara. I don’t mean to imply anything about Western Sahara’s rightful status here.
So, who were the Marinids and how did they come to rule Morocco? To answer that question we first need to cover the decline of the Almohad Caliphate, which preceded them. And to do that we need a little context. The Maghrib, or at least the part of it from Tunisia west, was one of the first places the Abbasid dynasty lost after they assumed the caliphate in 750. Al-Andalus, or Muslim Spain if you like, went very quickly as it became the refuge of the overthrown Umayyad dynasty, but the furthest parts of the Maghrib–i.e., Morocco–became effectively independent in 788 with the arrival of Idris I, founder of the Idrisid dynasty. Idris was fleeing a failed Alid (early Shiʿa) rebellion and basically ran as far away from Baghdad as he could, which meant in his case Ibn Battuta’s hometown of Tangier. He was taken in by an Amazigh (another word for Berber without the latter term’s historical baggage) tribe called the Awraba and founded the Idrisid dynasty, considered the earliest forerunner of modern Morocco.
Things get a little wild after the Idrisids. In the 10th century the Sanhaja Amazigh confederation began to amass territory along the west coast of sub-Saharan Africa. In the 11th century, under the guidance of a religious leader named Abdullah ibn Yasin, a group of Sanhaja conquered Morocco and swept into al-Andalus to defend it from its Christian enemies, restoring central authority after the collapse of the Umayyad caliphate had reduced that region to a bunch of squabbling city-states. They were known as the Almoravids, or al-Murabitun, after the ribat desert fort/mission structures they built and used. They lasted until the middle of the 11th century, when they were defeated by the Christians in al-Andalus and overthrown in Morocco by a religious revivalist movement centered around the Masmuda Amazigh confederation and founded by a preacher named Ibn Tumart.
Ibn Tumart developed his own rigid Islamic theology that heavily emphasized the oneness of God–hence, his followers were called the Almohads or al-Muwahhidun, a name that means “monotheists” or “unitarians,” though definitely not in the way you might think of Unitarians today. His followers believed him to be the promised end-times Mahdi, though clearly we’re all still here so that wasn’t the case, and Ibn Tumart believed that it was incumbent upon all Muslims not just to get their faith right, but to make sure that other Muslims were getting it right as well–apparently, by force if necessary. He died fighting the Almoravids in 1128. Ibn Tumart’s successor, a Zenata Amazigh who called himself Abd al-Muʾmin (“servant of the believer”) took the title of “caliph” as opposed to a more straightforward title like “sultan,” reflecting perhaps a sense that he was only a caretaker for Ibn Tumart’s movement or perhaps the belief that the Almohads should rule all Muslims as the caliphs had once done. It was under his leadership that the Almohads put an end to the Almoravids by capturing Marrakesh in 1147. They assumed the Almoravids’ former role as the dominant power in al-Andalus as well as in Morocco, and they extended their control over most of the Maghrib, well into modern-day Libya.
Increasing pressure from the Christians in al-Andalus coupled with internal breakdowns to doom the Almohads. Internally, the caliphate quickly became less about propagating Ibn Tumart’s message and more about continuing the dynasty founded by Abd al-Muʾmin, which turned many off. The Caliph Abu Yusuf Yaʿqub (d. 1199) defeated large Christian invasions in al-Andalus three times, only to have them claw back each time once he’d returned to North Africa. He also tried to argue that Ibn Tumart was not the Mahdi, which you would think would have been obvious by this point since Ibn Tumart was, uh, dead, and tried to institute a more orthodox kind of Islam in the caliphate, which alienated religious scholars and threatened to eradicate the only thing that held the Almohads’ broad Amazigh coalition together. After his death the caliphate began to break apart. It first lost its easternmost territories, and between 1228 and 1248 a massive Christian offensive left only the kingdom of Granada in Muslim hands in Iberia–and it belonged to the Nasirid dynasty, not the Almohads.
The death (apparently he was gored by a bull) of the Caliph Yusuf II in 1224, when he was only maybe 20 or 21 and hadn’t yet fathered an heir, really kicked the dynastic turmoil up a notch. A civil war ensued, in fact, one that led directly to the dynasty’s collapse. Rival caliphs controlled different parts of the empire–one of these, Idris al-Maʾmun (d. 1232), even fully repudiated the Almohad theology in favor of orthodox Sunnism, which only added to the collapse. Revolt after revolt carved pieces of the Almohads’ territory away–Tunisia was first to go, to the Hafsids, then Algeria to the Zayyanids.
It was in one of those revolts, beginning in 1244, that the Almohads began slowly losing Morocco to the Marinids. A Zenata Amazigh people that took its name from a distant ancestor, the Marinids had no particular religious fervor driving them, but instead tried to carve out an autonomous entity for themselves in eastern Morocco and the Rif Mountains in the 1210s and basically continued to resist Almohad attempts to subjugate them. As the Almohads continued to weaken, the Marinids simply absorbed more and more of their remaining territory until, by the final end of the dynasty in 1269, Marrakesh was all the Almohads had left.
The Almohads didn’t rule for very long, but they represent an important era in the history of the Maghrib as a distinct part of the Islamic world, because they were the first and really only political entity to conquer and control the whole place. The region had been part of the Umayyad caliphate, yes, but the Almohads were a local, Amazigh dynasty ruling this region as a separate entity, not as part of a larger empire controlled from elsewhere. Whatever commonalities in politics and especially religion you might find in the region from western Libya to Morocco, it’s likely that the Almohads had something to do with that. And the ramifications of their collapse were still being felt in Ibn Battuta’s time.