However, the Tang did manage to restore at least indirect control over former Tang territories as far west as the Hexi Corridor and Dunhuang in Gansu. In 848 the ethnic Han Chinese general Zhang Yichao (799–872) managed to wrestle control of the region from the Tibetan Empire during its civil war. Shortly afterwards Emperor Xuānzong of Tang (r. 846–859) acknowledged Zhang as the protector (防禦使, Fangyushi) of Sha Prefecture and jiedushi military governor of the new Guiyi Circuit.
The Tang dynasty recovered its power decades after the An Lushan rebellion and was still able to launch offensive conquests and campaigns like its destruction of the Uyghur Khaganate in Mongolia in 840–847.