Idris) proclaimed Mauritania's independence of the Abbasid Caliphate of Baghdad, the Tunisian Jews joined his army under the leadership of their chief, Benjamin ben Joshaphat ben Abiezer. They soon withdrew, however; primarily because they were loath to fight against their coreligionists of other parts of Mauritania, who remained faithful to the caliphate of Baghdad; and secondarily, because of some indignities committed by Idris against Jewish women. The victorious Idris avenged this defection by attacking the Jews in their cities. The Jews were required to pay a capitation-tax and provide a certain number of virgins annually for Idris' harem. The Jewish tribe 'Ubaid Allah preferred to migrate to the east rather than to submit to Idris; according to a tradition, the Jews of the island of Djerba are the descendants of that tribe. In 793 Imam Idris was poisoned at the command of caliph Harun al-Rashid (it is said, by the governor's physician Shamma, probably a Jew), and circa 800 the Aghlabite dynasty was established. Under the rule of this dynasty, which lasted until 909, the situation of the Jews in Tunis was very favorable. As of old, Bizerta had a Jewish governor, and the political influence of the Jews made itself felt in the administration of the country. Especially prosperous at that time was the community of Kairwan (Kairouan), which was established soon after the foundation of that city by Uqba bin Nafi in the year 670. A period of reaction set in with the accession of the Zirite Al-Mu'izz (1016–62), who persecuted all heterodox sects, as well as the Jews. The persecution was especially detrimental to the prosperity of the Kairwan community, and members thereof began to emigrate to the city of Tunis, which speedily gained in population and in commercial importance. The accession of the Almohad dynasty to the throne of the Maghreb provinces in 1146 proved disastrous to the Jews of Tunis. The first Almohad, 'Abd al-Mu'min, claimed that Muhammad had permitted the Jews free exercise of their religion for only five hundred years, and had declared that if, after that period, the messiah had not come, they were to be forced to embrace Islam. Accordingly, Jews as well as Christians were compelled either to embrace Islam or to leave the country. 'Abd al-Mu'min's successors pursued the same course, and their severe measures resulted either in emigration or in forcible conversions. Soon becoming suspicious of the sincerity