Siege of Xiangping

The Siege of Xiangping (July-September 238) was the decisive battle between the armies of the Kingdom of Cao Wei and the rebel army of Gongsun Yuan, the self-styled "King of Yan". The 40,000-strong Wei army under Sima Yi crushed Gongsun Yuan's Rebellion after defeating the King of Yan's army and storming his fortress.

Background
The northern warlord Gongsun Yuan, the ruler of the Liaodong commandery on the Korean border, came from a long line of powerful warlords. The Gongsun clan had nearly been wiped out as the result of a war with Yuan Shao in 199 CE, leaving just Gongsun Yuan to carry on the family's legacy. He was a vassal of Cao Wei, the northernmost of the Three Kingdoms, but he truly desired independence. In 238, he was convinced to rebel against Wei by Wei's southeastern rival, Eastern Wu, and he declared himself "King of Yan". He raised an army of tens of thousands of soldiers to defend his new kingdom, and Emperor Cao Rui sent Sima Yi with 40,000 Wei troops to crush the uprising.

Siege
Sima Yi and his 40,000-strong army encamped at Liaodong and laid siege to Gongsun Yuan, whose army occupied the fortress of Xiangping. Sima Yi brought along his sons Sima Shi and Sima Zhao, hoping to teach them how to lead armies on the battlefield. Sima Shi was sent to attack from the south to draw the rebels' attention, while Sima Zhao would set up camp to the east and prepare to strike at the rebels while their defenses were thin. The rebel forces in the south were forced to run into the valleys, and Gongsun Yuan attempted a massive counterattack along the front lines, breaking his own defensive positions. This included an ambush of Sima Zhao's assault unit in the east by Gongsun Heng's forces, which was repelled after Sima Yi led forces to rescue his son. Gongsun Yuan then sent Wei Yan and Su Shu to attack out of Xiangping Castle, but Sima Yi planned to assault the castle from the northeastern cliff. The rebel forces were routed as they left the castle, and Sima Yi's ambush took the defenders by surprise, demoralizing them. Wang Jian attempted to surrender, but Sima Yi said that there were five options in war: "fight, defend, flee, surrender, or die," and that the rebels were inept at the first two and had the temerity to surrender, which led him to believe that they deserved death. In the end, Gongsun Yuan was wounded and captured by the Wei forces, and Sima Yi ordered his execution. All 2,000 officeholders under the rebel regime and 7,000 soldiers over the age of 14 were executed by the Wei army.

Aftermath
The Kingdom of Yan was crushed, and the Gongsun clan was eliminated. Sima Yi returned to Luoyang, but he grew tired of fighting battles against unworthy opponents; his only serious rival, Zhuge Liang, had died in 234 CE. After Cao Rui died, Cao Fang became emperor, and he appointed Cao Shuang General-in-Chief. Sima Yi chose to retire from public life in order to avoid conflict with Cao Shuang, as well as to prevent him from having to fight unworthy rivals. His sons would be left to command his armies during his retirement.