 The Buddhist entitles of Dunhuang and Khotan had a tight-knit partnership, with intermarriage between Dunhuang and Khotan's rulers and Dunhuang's Mogao grottos and Buddhist temple funded and sponsored by the Khotan royals, depicted in the Mogao grottoes.In the Mogao caves, the rulers of Khotan hired artists to paint divine figures alongside the Khotans to give them strength against their Turkic rivals.In 840, after the Uyghur Khanate in Mongolia had been conquered by the Kirghiz, Uyghurs migrated southwards into the Tarim Basin, to Kara-khoja and to Beshbalik near today's Turpan and Urumqi.