the Rashidun Caliphate in July 633, after a fiercely fought siege. The Arabs retained the name (Fīrūz Shābūr) for the surrounding district, but the town itself became known as Anbar (Middle Persian word for "granary" or "storehouse") from the granaries in its citadel, a name that had appeared already during the 6th century. According to Baladhuri, the third mosque to be built in Iraq was erected in the city by Sa'd ibn Abi Waqqas. Ibn Abi Waqqas initially considered Anbar as a candidate for the location of one of the first Muslim garrison towns, but the fever and fleas endemic in the area persuaded him otherwise. According to medieval Arabic sources, most of the inhabitants of the town migrated north to found the city of Hdatta south of Mosul. The famous governor al-Hajjaj ibn Yusuf cleared the canals of the city. Abu'l-Abbas as-Saffah (), the founder of the Abbasid Caliphate, made it his capital in 752, constructing a new town half a farsakh () to the north for his Khurasani troops. There he died and was buried at the palace he had built. His successor, al-Mansur (), remained in the city until the founding of Baghdad in 762. The Abbasids also dug the great Nahr Isa canal to the south of the city, which carried water and commerce east to Baghdad. The Nahr al-Saqlawiyya or Nahr al-Qarma canal, which branches off from the Euphrates to the west of the city, is sometimes erroneously held to be the Nahr Isa, but it is more likely that it is to be identified with the pre-Islamic Nahr al-Rufayl. It continued to be a place of much importance throughout the Abbasid period. Caliph Harun al-Rashid () stayed at the town in 799 and in 803. The town's prosperity was founded on agricultural activities, but also on trade between Iraq and Syria. The town was still prosperous in the early 9th century, but the decline of Abbasid authority during the later 9th century exposed it to Bedouin attacks in 882 and 899. In 927, the Qarmatians under Abu Tahir al-Jannabi sacked the city during their invasion of Iraq, and the devastation was compounded by another Bedouin attack two years later. The town's decline accelerated after that: while the early 10th-century geographer Istakhri still calls the town modest but populous, with the ruins of the buildings of as-Saffah still visible, Ibn Hawqal and al-Maqdisi, who wrote