A Tunisian city, often transliterated in English as Kairouan, which became the capital city of the Aghlabids and later of the Fatimids .