Western Turkic Khaganate
In 657 the Western Turkic Khaganate was defeated by the Tang dynasty, after which the Uyghurs defected to the Tang. Prior to this the Uyghurs had already shown an inclination towards alliances with the Tang when they fought with them against the Tibetan Empire and Turks in 627.