(Kashgar and the Tarim Basin), and the Turfan area, each often ruled separately by competing Chagatayid descendants, the Dughlats, and later the Khojas. Islam was also spread by the Sufis, and branches of its Naqshbandi order were the Khojas who seized control of political and military affairs in the Tarim Basin and Turfan in the 17th century. The Khojas however split into two rival factions, the Aqtaghlik Khojas (also called the Afaqiyya) and the Qarataghlik Khojas (the Ishaqiyya). The legacy of the Khojas lasted until the 19th century. The Qarataghlik Khojas seized power in Yarkand where the Chagatai Khans ruled in the Yarkent Khanate, forcing the Aqtaghlik Afaqi Khoja into exile. Qing rule In the 17th century, the Buddhist Dzungar Khanate grew in power in Dzungaria. The Dzungar conquest of Altishahr ended the last independent Chagatai Khanate, the Yarkent Khanate, after the Aqtaghlik Afaq Khoja sought aid from the 5th Dalai Lama and his Dzungar Buddhist followers to help him in his struggle against the Qarataghlik Khojas. The Aqtaghlik Khojas in the Tarim Basin then became vassals to the Dzungars. The expansion of the Dzungars into Khalkha Mongol territory in Mongolia brought them into direct conflict with Qing China in the late 17th century, and in the process also brought Chinese presence back into the region a thousand years after Tang China lost control of the Western Regions. The Dzungar–Qing War lasted a decade. During the Dzungar conflict, two Aqtaghlik brothers, the so-called "Younger Khoja" (), also known as Khwāja-i Jahān, and his sibling, the Elder Khoja (), also known as Burhān al-Dīn, after being appointed as vassals in the Tarim Basin by the Dzungars, first joined the Qing and rebelled against Dzungar rule until the final Qing victory over the Dzungars, then they rebelled against the Qing, an action which prompted the invasion and conquest of the Tarim Basin by the Qing in 1759. The Uyghurs of Turfan and Hami such as Emin Khoja were allies of the Qing in this conflict, and these Uyghurs also helped the Qing rule the Altishahr Uyghurs in the Tarim Basin. The final campaign against the Dzungars in the 1750s ended with the Dzungar genocide. The Qing "final solution" of genocide to solve the problem of the Dzungar Mongols created a land devoid of Dzungars, which was followed by the Qing sponsored settlement of millions of other people in Dzungaria. In northern Xinjiang,