After Ibn Battuta left Marinid Morocco he entered the Kingdom of Tlemcen, under the control of the Zayyanid Dynasty, sometimes also known as the Abd al-Wadids. They ruled a territory that to some degree corresponds with modern Algeria, or at least the coastal parts of modern Algeria, as you can see on the map:
OK, so that map is circa 1400, so it’s a little after Ibn Battuta’s time, but you get the idea. It also has the “Zirids” ruling the territory between Wattasid Morocco and Hafsid Tunisia. I’ll be honest, I have no idea why that is. I inherited this map in grad school, so I didn’t scan it myself and don’t have any context for why the text whence it came identified the Zayyanids as the Zirids, who ruled that territory from the late 10th century through the mid 12th century and were definitely not around in 1400. Just mentally swap them out and put the Zayyanids in there, though, and you’ll be in good shape. Or use this map, which I found after I wrote this post, instead:
Like the Marinids, the Zayyanids emerged from a branch of the Zenata Amazigh people. They controlled area around the city of Tlemcen, and when that city became a key administrative center for the Almohads the Zayyanids became important players in the Almohad Caliphate as bureaucrats and warriors. In 1230, as the Almohads were very much circling the drain, they appointed the Zayyanid chief Jabir ibn Yusuf as governor of Tlemcen, and the city more or less became Zayyanid property. It was another Zayyanid, Yaghmurasen ibn Zyan (d. 1283), who was serving as governor of Tlemcen when the Almohads lost control of the region in 1236. His decision to declare Tlemcen independent helped hasten the Almohads’ decline and makes him the founder of the Zayyanid dynasty.
For the next decade or more Yaghmurasen tried to consolidate control over Tlemcen and its surrounding area. He survived a successful invasion by the Hafsids in 1241, submitting to their suzerainty in return for getting his city back, and a failed invasion by the remnants of the Almohads in 1248. After the latter invasion the Zayyanids went on the offensive against the other Zenata tribes in what is today western Algeria. Under Yaghmurasen and his son, Uthman (d. 1303), the Zayyanids began to expand their territory across northern Algeria sometimes via military conquest but also frequently through crafty diplomacy. Yaghmurasen captured the city of Sijilmasa, a northern way-station on the trans-Saharan trade network, in 1263, but the Marinids took it from him ten years later. The loss hurt, but much of Sijilmasa’s commercial activity flowed through Tlemcen on the way to Europe anyway, and that continued despite the fact that the two cities came to be ruled by different and often opposed dynasties. So the Zayyanids continued to benefit from the overland trade with West Africa. By 1290 the Zayyanids’ territory was pretty well established along the lines of what you see above.
As any self-respecting dynasty would have done in the 13th century, the Zayyanids sought to broadcast their power and legitimacy by developing their capital city. Tlemcen became an important center of religion and scholarship, and its commercial and diplomatic ties with the Christian kingdoms of Iberia (especially Aragon) gave it a very cosmopolitan character, but by the late 1200s Aragonese influence over the city was reaching pretty significant levels. In Ibn Battuta’s day Tlemcen and Aragon had a robust commercial relationship based largely around gold and slaves, while an Aragonese militia was permanently stationed in Tlemcen and the Zayyanids had agreed to provide a military force to Aragon. They also agreed that the head of that Aragonese militia would be considered the leader of all Europeans in Zayyanid domains and that half of all the customs duties the Zayyanids collected from European merchants would be sent to Aragon, a tribute payment in all but name.
The close ties between Aragon and Tlemcen were severed in the 1330s by the Marinids. As you may recall, the Marinids began a period of eastward expansion while Ibn Battuta was off on his journey, and in 1337 they captured Tlemcen. The Marinids were much cooler toward Aragon than the Zayyanids had been, and their ~11 year occupation of Tlemcen dealt a heavy blow to Aragon’s influence there. The 14th century for the Zayyanids was basically a series of Marinid invasions, from their unsuccessful 1299-1307 siege of Tlemcen to their 1337-1348 occupation to their second occupation, from 1353 through 1358, to occupations in 1360, 1370, and 1383-1388. After the latter the Zayyanids had to submit to Marinid suzerainty as they’d done with the Hafsids back in the 1240s. But by the early 15th century the Marinids were falling apart internally and were increasingly controlled by the Nasirids from Granada, and the Zayyanids were able to resume their control over the region.
The Zayyanids also periodically clashed with the Hafsids to their east. While Yaghmurasen had submitted to the Hafsids back in 1241, by the 14th century the Zayyanids had long since dropped that pretense. Ibn Battuta would have journeyed through a war zone along Tlemcen’s eastern border, in fact, because between 1320 and 1331 the Zayyanids tried very hard to capture the port city of Béjaïa from the Hafsids. Their effort ultimately failed. In 1424, with the Marinids really collapsing, the Zayyanids once again pledged themselves as Hafsid vassals.
The end of the Zayyanids came, as it did for the Hafsids, with the arrival of the Ottomans to North Africa. And that development was tied to the successful Christian conquest of Iberia in 1492 and the threat that Spain and Portugal then posed to the Muslim North African dynasties. Spanish forces captured the city of Oran from the Zayyanids in 1509, highlighting this threat. It was around this time that the center of political gravity in the future Algeria moved from Tlemcen to Algiers, as Spanish attacks on the former city made it increasingly untenable as a capital. The Ottomans moved into North Africa as the self-proclaimed protectors of Islam, and in 1554 they conquered Tlemcen and put an end to the Zayyanid dynasty.