The Hafsids were a Berber dynasty that ruled Ifriqiya, modern Tunisia and eastern Algeria, from 1229 to 1574. They claimed descent from the Almohads. They made Tunis a major Mediterranean trade center.
The Hafsids often fought Spain, local tribes, and Ottoman corsairs. They became an Ottoman vassal in the 16th century. The dynasty ended when the Ottomans conquered Tunis in 1574.