Emperor Yuan of Jin (; 276 – 3 January 323Emperor Yuan's biography in the Book of Jin indicates that he was 47 (by East Asian reckoning) when he died on the jichou day of the leap month of the first year of the Yong'chang era. Volume 92 of Zizhi Tongjian also recorded the same date of death.), personal name Sima Rui (), courtesy name Jingwen (), was an emperor of the Jin dynasty and the first emperor of the Eastern Jin. He was the son of Sima Jin (), the grandson of Prince of Langya Sima Zhou and the great-grandson of Sima Yi.

Yuan was stationed south of the Yangtze in Jiankang during the Upheaval of the Five Barbarians, where he avoided the chaos that befell northern China. Primarily through the help of cousins Wang Dun and Wang Dao, he emerged as an authority figure within the empire, backed by the southern gentry clans and northern emigre families who fled to his domain for refuge. After Emperor Min of Jin was executed by the Han-Zhao dynasty in 318, Yuan proclaimed himself emperor and moved the capital to Jiankang. At his death he left the state under the heel of Wang Dun, but the Eastern Jin dynastyas it became knownlasted until its fall in July 420 and contended with the Sixteen Kingdoms in the north and (occasionally) in the southwest.

Early life Sima Rui was born in 276 in the Jin capital of Luoyang.(咸宁二年生于洛阳,...) Jin Shu, vol. 6 He was the son of Sima Jin (, heir to the princedom of Langya) and his wife, Xiahou Guangji (). However, there is a rumour which originates from the Chronicles of Jin (晉陽秋), written by the Eastern Jin historian, Sun Sheng (302–373), that Sima Rui was the product of an affair between Xiahou Guangji and a kinsman of the Cao Wei general, Niu Jin.(又初,元石圖有『牛繼馬後』,故宣帝深忌牛氏,遂為二榼共一口以貯酒,帝先飲佳者,以毒者鴆其將牛金。而恭王妃夏侯氏竟通小吏牛欽,而生元帝,亦有符雲。) Jin Yang Qiu, cited in vol.98 of Taiping Yulan. This account is often included in later biographies of Sima Rui such as vol.96 of the Book of Wei and vol.6 of the Book of Jin. However, in the Twenty-Four Histories, this account chronologically first appeared in (vol.27 of) Book of Song (compiled late 5th century) by Shen Yue. Most of Sun Sheng's writings, including Jin Yang Qiu, survive only as citations in other works. Sima Rui's grandfather Sima Zhou (prince of Langya and uncle of Emperor Wu of Jin) died in June 283, leaving Sima Jin to inherit the princedom; Xiahou became princess consort. Sima Jin died on 9 March 290Xin'chou day of the second month of the first year of the Tai'xi era, according to Emperor Wu's biography in the Book of Jin at age 35 (by East Asian reckoning),Jin Shu, vol. 38 and Sima Rui became Prince of Langya. The Book of Jin described him as steady, quick-witted and magnanimous.

About two months after Sima Rui became Prince of Langya, Emperor Wu died. Wu's successor, Emperor Hui, was developmentally disabled and controlled by several regents during his reign. As the struggle to become Emperor Hui's regent (known as the War of the Eight Princes) intensified, Sima Rui remained aloof from political developments to protect himself. His ability to hide his talents ensured that most people were unaware of them. Ji Shao (, son of Ji Kang),Jin Shu, vol.89 who was Palace Attendant, saw that Sima Rui was special: "The Prince of Langya has an extraordinary appearance, which does not belong to that of a subject."(及惠皇之际,王室多故,帝每恭俭退让,以免于祸。沈敏有度量,不显灼然之迹,故时人未之识焉。惟侍中嵇绍异之,谓人曰:"琅邪王毛骨非常,殆非人臣之相也。") Jin Shu, vol.06. It is possible that Ji Shao did not meant for his comments to be complimentary, as implying that a distant relative of the imperial clan would not remain a subject almost certainly meant that he would be an usurper. Historically, Ji Shao was famous for dying in his attempt to shield Emperor Hui from arrows during an attack.

In 304, during the War of the Eight Princes, Sima Rui joined the Prince of Donghai Sima Yue's campaign against the Prince of Chengdu Sima Ying as a minor general. After Sima Ying defeated Sima Yue, Sima Ying executed Sima Rui's uncle Sima Yao (, prince of Dong'an) on 18 September. He fled back to his principality, Langxieroughly modern Weifang, Shandongunder the counsel of Sima Yue's assistant Wang Dao, whom he befriended during the campaign. He first tried to return to Luoyang, but when he was about to cross the Yellow River he was stopped by guards who were instructed to stop any nobles or high-level officials from crossing; Sima Ying had ordered that, fearing that nobles would desert him or plot against him. His guard, Song Dian, () arrived with the ruse that they were both construction workers; the guards then allowed them to cross. After Sima Rui arrived in Luoyang, he and his mother went to Langxie and spent the next few years away from the civil wars.(太弟颖怨东安王繇前议,[永兴元年]八月,戊辰,收繇,杀之。初,繇兄琅邪恭王觐薨,子睿嗣。睿沈敏有度量,为左将军,与东海参军王导善。导,敦之从父弟也;识量清远,以朝廷多故,每劝睿之国。及繇死,睿从帝在邺,恐及祸,将逃归。颖先敕诸关津,无得出贵人;睿至河阳,为津吏所止。从者宋兴自后来,以鞭拂睿而笑曰:“舍长,官禁贵人,汝亦被拘邪?”吏乃听过。至洛阳,迎太妃夏侯氏俱归国。) Zizhi Tongjian, vol. 85. Sima Ying killed Sima Yao, who had earlier advised Sima Ying to surrender (东安王繇曰:“天子亲征,宜释甲缟素出迎请罪。”颖不从,...).

In August 307, Sima Yue had been victorious in the aftermath of the War of the Eight Princes as the regent for Emperor Huai (Emperor Hui's successor and half-brother) seven months earlier. Under the advice of his wife, Princess Pei, he commissioned Sima Rui as military commander of parts of Yang Province (, modern Zhejiang and southern Jiangsu and Anhui) south of the Yangtze with his post at Jianye. Before his appointment, the region was controlled by rebel general Chen Min from 305 to 307. Many of the southern gentry clans initially backed Chen Min, but became unhappy with his rule and returned to Jin by overthrowing him. His mother, Princess Dowager Xiahou, died during his first year at Jiangdong.(永嘉元年,薨于江左...) Jin Shu, vol.31. The first year of the Yong'jia era ended on 7 Feb 308 of the Julian calendar.

Among Sima Rui's staff, Wang Dao was a chief advisor. Since Sima Rui was not well known when he arrived in Jianye, few from the southern gentry clans would visit and support him. Under Wang Dao's counsel, Sima Rui visited He Xun (; great-grandson of He Qi) and Gu Rong (; grandson of Gu YongJin Shu, vol. 68) and invited them to serve in his administration. He and Gu were well regarded by the local population, who eventually began to trust Sima Rui's leadership. Wang Dao and his cousin, general Wang Dun, served in key roles; it was said at the time that the Tianxia was ruled equally by the Simas and the Wangs.(《晉書·王敦傳》:帝初鎮江東,威名未著,敦與從弟導等同心翼戴,以隆中興,時人為之語曰:「王與馬,共天下。」) Book of Jin, vol.98

While Sima Rui was in the south, Sima Yue was preoccupied with quelling rebellions and fighting the Han-Zhao dynasty in the north. Sima Rui was essentially out of Sima Yue's reach; for the first few years he had to check commander Zhou Fu, who controlled Yang province north of the Yangtze. The deadlock was finally broken in February 311 when Zhou Fu, under fire by the imperial court for suggesting that they move to his base in Shouchun, was forced into rebellion. Sima Rui, now with grounds to attack Zhou Fu, ordered his forces to march north of the Yangtze and annexed the rest of Yang Province.

After the fall of Luoyang In July 311, after Sima Yue died in April, Luoyang fell to Han forces and Emperor Huai was captured during the Disaster of Yongjia. A high-ranking minister, Xun Fan, escaped from Luoyang and founded a provisional government near the former capital. With Xun Fan's assent, Sima Rui began to exercise more imperial power; he was proclaimed leader of the Jin alliance, and was given authority to appoint and dismiss chief officials. With many officials fleeing south of the Yangtze, Wang Dao advised Sima Rui to recruit talented men from northern emigre families to serve in his administration. Sima Rui chose more than a hundred officials from the northern emigres, and they were known as the "106 Officials".

South of the Huai river and west of Sima Rui, Jiang province (, modern Jiangxi) inspector Hua Yi and Yu province (, present-day central Anhui) inspector Pei Xian refused to acknowledge Sima Rui's authority. The prince sent Wang Dun to campaign against them, killing Hua and forcing Pei to flee before replacing them with his own followers. In the central Yangtze region, the provinces of Jing (, present-day Hubei) and Xiang (, present-day Hunan) had been struggling with a refugee crisis due to the war with the Cheng-Han dynasty in Sichuan. These refugees (primarily led by Du Tao) rebelled in 311, ousting the inspector of Xiang and defeating the inspector of Jing Wang Cheng (younger brother of Wang Yan). Sima Rui expanded his influence into the central Yangtze, installing his own Inspector of Xiang and convincing Wang Cheng to resign. Forces commanded by Wang Dun and other generals, including Tao Kan and Zhou Fang, managed to subjugate the agrarian rebels resisting Jin rule in Jing and Xiang.

Although Sima Rui had initially relied on the southern gentry clans to consolidate his rule in the Jiangnan, he began relying more on the northern emigre families as they continued to flock to him. The southern gentry were divided about his shift of trust; most were willing to tolerate it, but others (such as Zhou Qi from the Zhou clan of Yixing) became resentful of the northern emigres. The hardliners rallied around Zhou Qi and his family to oust the northern emigres and force Sima Rui to restore the southern clans to power. Their conspiracies in 313 and 315 were exposed and did not attract enough support, however, and failed to have a significant impact on Sima Rui.

In 313, after Emperor Huai was executed by the Han, Sima Yea nephew of Emperor Huaiwas declared emperor (and posthumously known as Emperor Min) in Chang'an. Due to the naming taboo against Emperor Min's given name of "Ye" (業), Sima Rui's headquartersJianye (建業)was renamed Jiankang (建康), a name it kept for several centuries. Sima Rui accepted the title of Left Prime Minister, but took no actions in aid of the emperor. When Sima Ye was alive, the prince showed little interest in lending his forces to help pacify the north. When his general and former refugee leader Zu Ti asked to lead an army north, he gave Zu supplies for only one thousand men with no actual troops; Zu had to enlist his own soldiers before recovering a number of cities south of the Yellow River.

Chang'an fell to Han forces in 316, and Emperor Min was captured. Sima Rui declared that he was going to act against Han, but then claimed a lack of supplies and cancelled the campaign. In spring 317, his officials asked him to take the throne. Sima Rui declined initially but took the title "King of Jin" (a title previously used by Sima Zhao and Emperor Wu while they were regents of Cao Wei), rather than emperor, on 6 April 317.Xin'mao day of the third month of the first year of the Jian'wu era, according to Emperor Yuan's biography in the Book of Jin. Volume 90 of Zizhi Tongjian recorded the same date for the event. He made his son, Sima Shao, crown prince on 1 May of that year.The first bing'chen day after Sima Rui became King of Jin, of the fourth month of the first year of the Jian'wu era, according to Emperor Yuan's biography in the Book of Jin. Volume 90 of Zizhi Tongjian recorded the same date for the event.

Early reign and loss of Northern China