Juqu Mengxun then set a trap for both Juqu Nancheng and Duan Ye. He set a date with Juqu Nancheng to offer sacrifices to the god of Lanmen Mountain (蘭門山, near Zhangye) on a vacation day, but submitting a false report through the official Xu Xian () that Juqu Nancheng was set to rebel and would start the rebellion on a day that he requested permission to sacrifice to the god of Lanmen Mountain. When Juqu Nancheng requested Duan Ye for such permission, Duan Ye arrested him and ordered him to commit suicide. Juqu Nancheng, who had realized Juqu Mengxun's plan by this point, told Duan Ye that this was a sign that Juqu Mengxun was about to rebel and that he should keep Juqu Nancheng alive, and then when Juqu Mengxun rebels he could counterattack. Duan Ye, not believing in Juqu Nancheng, executed him. Juqu Mengxun then cited Duan Ye's execution of Juqu Nancheng to ask his people to rise against Duan Ye, and the people indeed rose in rebellion, because of the high regard they had for Juqu Nancheng. In a last-ditch effort, Duan Ye released the general Tian Ang (), whom he had suspected of treachery earlier and imprisoned, and put Tian in charge of an army against Juqu Mengxun, along with Liang Zhongyong. Tian, however, quickly surrendered to Juqu Mengxun, and Duan Ye's remaining troops collapsed. Zhangye fell, and despite Duan Ye's pleas, Juqu Mengxun executed him and took over the throne.