 In 744 the Tang defeated the Türgesh, and drove the Tibetans out of Pamir.A few years later, war between Ferghana and Tashkent, with the Han supporting Fergahna, resulted in Arab intervention, and in the Battle of Talas (751) the Tang lost to the Abbasid Caliphate, which did not proceed to Xinjiang further into Xinjiang.The devastating Anshi Rebellion (755–763) ended Tang presence in the Tarim Basin, when the Tibetan Empire invaded the Tang on a wide front from Xinjiang to Yunnan, sacking the Tang capital Chang'an in 763, and taking control of the southern Tarim.