The principality of Farghana was under Western Turk rule until it was destroyed by Tang China in 657 and after that under the Anxi Protectorate. It was invaded by the Umayyad Arab general Qutayba ibn Muslim during the Muslim conquest of Transoxiana. Farghana, along with Khujand, was shortly raided after Qutayba's victory over Gurak.