Tlemcen was founded by the Romans in the 4th century CE under the name of Pomaria as a military outpost. It was an important city in North Africa see of the Roman Catholic Church in the century in which it was built, where it was the center of a diocese. Itsbishop, Victor, was a prominent representative at the Council of Carthage in 411, and its bishop Honoratus was exiled in 484 by theVandal king Huneric for denying Arianism. It was a center of a large Christian population for many centuries after the city's Arabconquest in 708. In the later eighth century and the ninth century, the city became a Kingdom of Banu Ifran of the Kharijite sufri.These same Berber Kharijis also began to develop various small Saharan oases and to link them into regular trans-Saharan caravan routes terminating at Tlemcen—beginning a process that would determine Tlemcen's historical role for almost all of the next millennium.
In 1082 the Almoravid leader Yusuf ibn Tashfin founded the city of Tagrart ("Encampment" in the Berber language), which merged with the existing settlement, now called Agadir and since then became known as Tlemcen (Tilimsan). Tlemcen probably passed from Almoravid to Almohad control in the mid-twelfth century. However, in the early thirteenth century, Ibn Ghaniya attempted to restore Almoravid control of the Maghreb. In about 1209, the region around Tlemcen was devastated by retreating Almoravid forces, not long before their final defeat by the Almohads at the Battle of Jebel Nafusa in 1210. Despite the destruction of Tlemcen's already-feeble agricultural base, Tlemcen rose to prominence as a major trading and administrative center in the region under the succeeding reign of the Almohads.
On the collapse of Almohad rule in the 1230s Tlemcen became the capital of one of three successor states, the (Ziyyanid) kingdom of Tlemcen (1236 - 1554) and was ruled for centuries by successive Ziyyanid sultans. Its flag was a white crescent pointing upwards on a