In 237, the Wei emperor Cao Rui felt insecure about Gongsun Yuan's influence in the northeast, so he sent the general Guanqiu Jian to lead an army of Chinese, Wuhuan and Xianbei troops to attack Gongsun Yuan, but floods caused the campaign to be aborted. Gongsun Yuan declared himself "King of Yan" () and concluded an alliance with Eastern Wu. The following year, the Wei generals Sima Yi and Guanqiu Jian led a campaign against Gongsun Yuan. Gongsun Yuan was defeated and killed while his clan was exterminated. As a consequence, Liaodong and present-day northwest Korea became Wei territories.