Sima Yan's first important appearance in history was in 260, when forces loyal to his father, led by Jia Chong, defeated an attempt by the Wei emperor Cao Mao to take back power and killed Cao Mao. At that time, as a mid-level army general, he was commissioned by his father to escort the new emperor Cao Huan from his dukedom to the capital Luoyang. After his father was created the Duke of Jin on 9 December 263 in light of the army's conquest of Shu Han, he was named heir. However, at times Sima Zhao hesitated as to whether Sima Yan or his brother Sima You would be the more appropriate heir—as Sima You was considered talented and had also been adopted by Sima Shi, who had no biological sons of his own, and Sima Zhao, remembering his brother's role in the Simas' takeover of power, thought it might be appropriate to return power to his branch of the clan. However, a number of high level officials favored Sima Yan, and Sima Zhao agreed. After he was created the King of Jin on 2 May 264 (thus reaching the penultimate step towards usurpation), Sima Yan was created the Crown Prince of Jin.