When Cao Mao, the fourth emperor of the Wei Kingdom, ascended the throne, he was still a child ignorant of worldly affairs, serving as a puppet emperor with all state power controlled by Sima Zhao. Sima Zhao was domineering and overbearing; the court ministers resented him but dared not openly oppose him. The young emperor Cao Mao also disliked Sima Zhao. One day, Cao Mao summoned several key ministers to the palace and told them, "Sima Zhao's intentions are known to all on the street. He constantly plots to eliminate me and make himself emperor. It's better for us to strike first and capture him." The ministers agreed with Cao Mao's view and began recruiting conspirators to attack Sima Zhao. However, somehow Sima Zhao learned of this plot. Without hesitation, Sima Zhao ordered Cao Mao's execution and selected another child from the Cao clan, named Cao Huan, to be the new emperor. From then on, no one in the court dared to criticize Sima Zhao.
In 263 AD, Sima Zhao, who had fully seized control of the Wei state's government, planned to conquer the Shu state, and no one in the court dared to oppose his opinion. Moreover, by then, Shu had long lost its former glory; Zhuge Liang had died, and his successors Jiang Wan and Fei Yi were also dead, leaving only General Jiang Wei to manage state affairs. To fulfill Zhuge Liang's dying wish, Jiang Wei launched campaigns against Wei almost every year, but they yielded no results and instead weakened Shu's national strength. Sima Zhao believed it would be easy to capture Shu at this time, so he sent his general Zhong Hui with over 100,000 troops, while Deng Ai and Zhuge Xu each led 30,000 soldiers to advance into Shu territory. Zhong Hui was tasked with attacking Hanzhong, Deng Ai with attacking Tazhong, and Zhuge Xu was stationed at Yinping to prevent Jiang Wei from sending reinforcements if Chengdu was in danger. Upon learning of the Wei army's attack, Shu's General Jiang Wei led his troops to fight at Tazhong. Later, seeing that Hanzhong had been captured by Zhong Hui, he gathered his forces and hurried back, blocking Zhong Hui's army at Jiange (present-day Jiange, Sichuan). Jiange was a strategic pass into Shu, easy to defend and hard to attack, and Zhong Hui's over 100,000 troops were halted there, unable to advance. Despite several assaults, they failed to capture Jiange, and though Zhong Hui was anxious, he could not find a way to victory.
As time went on, the extended supply lines made resupply difficult, and Zhong Hui planned to withdraw his troops, but Deng Ai believed that a desperate fight still offered a chance for victory. He had Zhong Hui pin down Jiang Wei's army at Jian'ge Pass, then scouted the surrounding terrain and led a select force of elite soldiers along a hidden path west of Jian'ge to circle around to the south. Deng Ai and his men cut through brambles and thorns for over seven hundred li, fortunately without being detected by the Shu army. When they encountered a cliff that terrified the soldiers, Deng Ai wrapped himself in a blanket and rolled down, emerging unharmed thanks to the blanket's protection. Seeing this worked, the soldiers all wrapped themselves in blankets and rolled down the cliff, successfully reaching Jiangyou (present-day Jiangyou, Sichuan).
The Shu army stationed in Jiangyou was caught off guard by the sudden appearance of Wei forces, utterly shocked that the Wei army had bypassed Jian'ge and arrived here. In their panic, the Shu troops had no time to resist and were all captured by the Wei army. Then, Deng Ai led his men without rest, marching swiftly toward Mianzhu (southwest of present-day Mianyang, Sichuan).
The leader of the Zhushou Army was Zhuge Zhan, the son of Zhuge Liang. Deng Ai was reluctant to kill him, so he wrote a letter urging him to surrender and even promised to make him the Prince of Langya. Holding the letter, Zhuge Zhan's hands trembled with rage; he flew into a fury, drew his sword, and killed the messenger who had delivered it, then immediately ordered his troops to march out of the city for battle. However, the Shu army could not withstand Deng Ai's elite forces, and Zhuge Zhan was killed in action. His son, Zhuge Shang, was also slain, and the Wei army smoothly captured Jiangyou City.
With all obstacles cleared, Deng Ai marched straight toward Chengdu. Liu Shan, the last emperor of Shu, and his ministers had never imagined that Wei forces would break into the capital, and they panicked, huddling together to debate whether to flee or surrender. As Deng Ai's army drew closer, the city's residents fled to the mountains to hide. Emperor Liu Shan let out a long sigh and chose to surrender. Seeing their sovereign capitulate, the ministers also surrendered one after another.
Thus, Liu Shan, the last ruler of Shu, led his ministers out of the city gate and surrendered to Deng Ai. The Shu Han kingdom, painstakingly built by Liu Bei, fell.
Jiang Wei, upon hearing at Jian'ge that Chengdu had fallen and receiving various rumors about Liu Shan—some saying the Later Lord had defected to Wu, others claiming he had died in Chengdu—was extremely anxious and rushed his army toward Chengdu. Unexpectedly, halfway there, he learned that the Later Lord had already surrendered to Wei. Jiang Wei and his officers wept bitterly in grief. Realizing that his days of stubborn defense at Jian'ge had been entirely in vain, Jiang Wei nearly fainted.
After the fall of Shu Han, Jiang Wei constantly sought to restore the kingdom. To carry out his plan, he pretended to surrender to Zhong Hui along with his troops, aiming to stir up conflict between Zhong Hui and Deng Ai and provoke Zhong Hui into rebellion. However, Jiang Wei was unable to accomplish his plan alone, and soon he was killed during the internal strife among the Wei forces.