In 238, Sima Yi of Cao Wei led a successful campaign against his rival Gongsun Yuan, with the aid of Goguryeo. This led to the Chinese recapture of Liaodong as well as establishing great contacts with Korean kingdoms. By 242, the alliance between Cao Wei and Goguryeo broke down when Dongcheon of Goguryeo initiated a raid into Wei territory. In response, the Goguryeo–Wei War erupted in 244, ending with the sacking of the Goguryeo capital and resettlement of many of its inhabitants. 15 years later Goguryeo defeated Wei at Yangmaenggok.