The Hafsid dynasty was the first of the three successor dynasties to emerge from the collapse of the Almohad Caliphate in the mid 13th century. Unlike the Zayyanids, who had merely been regional governors in Tlemcen under the Almohads, and the Marinids, who had never been anything more than an enemy to the Almohads, the Hafsids had been part of the Almohad project from its earliest days as a religious revivalist movement. Unlike the Marinids and Zayyanids, the Hafsids emerged from the same Masmuda Amazigh background as Ibn Tumart and the Almohads. In fact, the dynasty could trace its ancestry to one of Ibn Tumart’s closest companions, Omar Abu Hafs al-Hentati, so it held a prominent position in the caliphate throughout its history.
When Ibn Battuta set out from Tangier on Hajj in 1325, Marinid Morocco was one of three kingdoms occupying the territory of the former Almohad Caliphate. Immediately to their east, and the next stop on Ibn Battuta’s journey, was the Kingdom of Tlemcen, ruled by the Zayyanid dynasty. This map should illustrate things for you:
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: