 Following the An Lushan Rebellion , the Khitans became vassals of the Uighurs , while simultaneously paying tributes to the Tang , a situation that lasted from 755 until the fall of the Uighurs in 840 . From 840 until the rise of Aboji , the Khitans remained a tributary of the Tang dynasty . 
