The rulers of Khotan were aware of the menace they faced since they arranged for the Mogao grottoes to paint a growing number of divine figures along with themselves. By the time the Turkic Uyghur (Buddhist) and the Turkic Kara-Khanid (Muslim) invaded, Khotan was the only state in the area that had not come under Turkic rule. It was during the Karakhanid reign that Buddhism lost territory to Islam in the Kashgar area. A long war ensued between Islamic Kashgar and Buddhist Khotan which eventually ended in the conquest of Khotan by Kashgar. Many tales emerged about the Kara-Khanid ruling family's war against the Buddhists, and it is said that either Satok Bughra Khan's nephew or his grandson Ali Arslan was slain by the Buddhists during the war. A shrine dedicated to Ali Arslan or Sultan Arslan Boghra who was killed in the campaign against Khoton was the most popular shrine of the region. His body was buried on the field of battle at Ordam Padshah, to the east of Yangi Hissar, but his head is preserved at a shrine in the Dolat Bagh, near Kashgar. Satok Boghra Khan's last campaign was undertaken against Turfan, where in 993 he fell ill and whence he was carried back, a dying man, to Kashgar. His son and successor, Hasan, is known to history as having ended the Samanid dynasty by the capture of Abdul Malik. A few years later both Hasan and his brother were killed by the Princes of Khotan. In what proved to be a pivotal moment in the Islamicization of the Tarim Basin, the Karakhanid leader Yusuf Qadir Khan conquered Khotan around 1006. After the occupation by the Karakhanids, Turki became the universal language. The oldest Kashgar book which has reached us, and which dates from 1068, is written in a pure Turki dialect. The Taẕkirah is a genre of literature written about Sufi Muslim saints in Altishahr. Written sometime in the period from 1700–1849, the Eastern Turkic language (modern Uyghur) " Taẕkirah of the Four Sacrificed Imams" provides an account of the Muslim Kara-Khanid war against the Khotanese Buddhists. The "Taẕkirah" uses the story of the Four Imams as a device to frame the chronicle, the Four Imams being a group of Islamic scholars from Mada'in city (possibly in modern-day Iraq), who travelled to help the Islamic conquest of Khotan, Yarkand, and Kashgar by the Kara-Khanid leader Yusuf Qadir Khan.