In 263, the Wei imperial court ordered Zhong Hui, Deng Ai and Zhuge Xu to lead separate armies to attack and conquer Wei's rival state, Shu Han. During and after the campaign against Shu, Zhong Hui framed Zhuge Xu and Deng Ai for cowardice and treason respectively, and seized command of their troops. By the time Shu surrendered to Wei in 263, Zhong Hui was in full control of all the Wei military forces in Shu territory. In 264, with backing from Jiang Wei, a former Shu general, Zhong Hui started a rebellion against Sima Zhao. However, the revolt failed when Zhong Hui's plan to purge several Wei officers – because he was worried that they would not support him – was leaked out. The officers escaped from custody, regrouped with their men, mutinied against Zhong Hui, and killed him and Jiang Wei.