and Lü Yan fell into a trap Qifu Gangui set and was killed. Lü Guang, in fear, withdrew to his capital Guzang (姑臧, in modern Wuwei, Gansu). In 398, Qifu Gangui sent Qifu Yizhou to attack Later Liang, and he recovered some of the territory previously lost. Later in 398, Qifu Yizhou battled Murong Shipi and defeated him. Murong Shipi, in fear, sent his son Murong Dangqi (慕容宕豈) as a hostage and sought peace. Qifu Gangui married the daughter of a clansman to Qifu Dangqi. In 400, Qifu Gangui moved his capital from Xicheng to Wanchuan (苑川, also in Baiyin). In summer 400, Later Qin's general, Yao Xing's uncle Yao Shuode (姚碩德) launched a major attack against Western Qin. Initially, Qifu Gangui was successful in cutting off Yao Shuode's supply line, but Yao Xing then personally came to Yao Shuode's aid. Qifu Gangui divided his army to try to ascertain Later Qin's intentions, but the armies lost communication in the fog, and Later Qin attacked them and greatly defeated them, taking nearly the entire Western Qin army captive. Yao Xing advanced to Fuhan (枹罕, in modern Linxia Hui Autonomous Prefecture, Gansu), forcing Qifu Gangui to flee back to Jincheng. With his army lost, however, Qifu Gangui concluded that he could not sustain a state any more, and instructed his officials to surrender to Later Qin, while he himself surrendered to Southern Liang's prince Tufa Lilugu, who welcomed him as an honored guest. Tufa Lilugu's brother Tufa Juyan (禿髮俱延) suspected Qifu Gangui's intentions, and suggested that Tufa Lilugu exile him to the Yifu (乙弗) tribe (probably west of the Qinghai Lake), a suggestion that Tufa Lilugu rejected. However, worried that Qifu Gangui would try to reestablish his state, he sent an army to watch over him. Qifu Gangui, fearing that he would be executed, then regained trust from Tufa Lilugu by sending Qifu Chipan, his brothers, and their mother to the Southern Liang capital Xiping as hostages. He himself, however, as soon as the Southern Liang guard was down, fled to Fuhan and surrendered to Later Qin. As Later Qin general Upon Qifu Gangui's arrival in the Later Qin capital Chang'an, Yao Xing created him the Marquess of Guiyi. In 401, Yao Xing inexplicably gave Qifu Gangui his entire captured army back to him and had him defend his old capital Wanchuan, effectively putting him back in the position he had