This article does not cite any sources. (December 2009) (Learn how and when to remove this template message)
Sima Yuanxian was the son of Sima Daozi the Prince of Kuaiji, the younger brother of Emperor Xiaowu and son of Emperor Jianwen, and he was born during the reign of his uncle Emperor Xiaowu. When Emperor Xiaowu was murdered by his concubine Honoured Lady Zhang in 396, he was succeeded by Emperor An, and Sima Daozi, as the emperor's uncle, became regent. Sima Daozi's trusted associates Wang Guobao (王國寶) and Wang Xu (王緒), because of their corrupt ways, quickly drew the ires of provincial officials Wang Gong (王恭) and Yin Zhongkan (殷仲堪), and in 397, Wang Gong and Yin started a rebellion, demanding that Wang Guobao and Wang Xu be killed. Sima Daozi, apprehensive of Wang Gong and Yin's power, executed Wang Guobao and Wang Xu, and Wang Gong and Yin withdrew. It was at this juncture that Sima Yuanxian, Sima Daozi's heir apparent, who was 15 but considered intelligent and capable, warned Sima Daozi that Wang Gong and Yin would one day again rebel. Sima Daozi, trusting his son, entrusted Sima Yuanxian with his personal guards.
In 398, the provincial official Yu Kai (庾楷), unhappy that part of his domain was given to Wang Yu (王愉), an official trusted by Sima Daozi, managed to persuade Wang Gong and Yin that the move was actually against them, and so Wang Gong and Yin started another rebellion. Sima Daozi, in fear, panicked and spent his days drinking, entrusting all important matters to Sima Yuanxian, who at the time appeared intelligent and resolute, reminding his followers of Emperor Ming. Soon, Sima Daozi persuaded Wang Gong's general Liu Laozhi (劉牢之) to betray him, and Wang Gong was captured and killed. Sima Daozi, under the suggestion of Huan Xiu (桓脩), then managed to cause dissension between Yin and his generals Huan Xuan and Yang Quanqi (楊佺期) by offering Huan and Yang key posts; although Huan and Yang nominally remained Yin's allies, Yin was forced to withdraw his troops, and from that point on no longer posed a major threat, as his domain had now been divided into three, with Huan and Yang each given a third. Sima Daozi, believing that his son had made the right predictions, trusted him even greater after this point. In late 398, the magician Sun Tai (孫泰), a friend of Sima Yuanxian's, who had gathered great following due to his magic, was exposed as planning a plot to take over the central government, and Sima Daozi ordered Sima Yuanxian to trap Sun Tai and execute him. Sun Tai's nephew Sun En fled to Zhoushan Island and planned revenge.
In 399, Sima Daozi was afflicted with illnesses and alcoholism, and one day, while Sima Daozi was drunk, Sima Yuanxian had Emperor An issue an edict removing Sima Daozi from his post as prime minister and transferring the authority to Sima Yuanxian. After he came to, Sima Daozi became furious at his son, but could do nothing. From this point on, while Sima Daozi was titular regent, Sima Yuanxian was the actual regent. He greatly trusted the strategist Zhang Fashun (張法順), and also introduced many trusted associates into the administration. While he appeared to have some abilities, he also was, according to traditional historians, wasting the government's money in luxury and not paying attention to the burdens of the people. Late in 399, Sun En, seeing how the only province remaining under Jin imperial government's actual control—Yang Province (揚州, modern Zhejiang and southern Jiangsu) -- had been mismanaged by Sima Yuanxian, launched a major attack from Zhoushan Island, briefly taking over nearly all of Yang Province and advancing on the capital Jiankang (modern Nanjing, Jiangsu). Sun's rebellion was soon put down by Liu Laozhi, and Sun fled back to Zhoushan (but would remain a menace for several years), but Yang Province had been laid to waste. Despite this, Sima Yuanxian grew increasingly extravagant and arrogant.
In 400, Sima Yuanxian had his son Sima Yanzhang (司馬彥璋) named the Prince of Donghai.
In early 401, the general Che Yin (車胤), as he saw that government officials were all offended by but fearful of Sima Yuanxian's arrogance, met with Sima Daozi to request Sima Daozi to try to rein in his son. In response, Sima Yuanxian threatened Che, and Che committed suicide.
In late 401, apprehensive of the growing power of Huan Xuan (who had in late 399 defeated and killed Yin Zhongkan and Yang Quanqi, seizing their domains and now controlled more than two thirds of Jin territory), Sima Yuanxian declared Huan a renegade and ordered an attack against Huan. However, he was largely dependent on Liu Laozhi's army, and Liu distrusted Sima Yuanxian. Meanwhile, Huan advanced east toward the capital and, after he made overtures to Liu, Liu turned against Sima Yuanxian. Jiankang fell to Huan, and Sima Yuanxian was captured and executed, along with all of his major associates and six sons.