According to Ibn Khaldun the town was founded by Banu Wargla who, accompanied by sections of the Maghrawa and Banu Ifran, left the Tlemcen region and founded Ouargla. These Berbers of Ouarghla then embraced Ibadi doctrines, which later made the town an attractive refuge for the citizens of Tahert.