Sima Yao was born in 362, when his father Sima Yu was Prince of Kuaiji and prime minister for his grandnephew, Emperor Ai. Sima Yao's mother, Li Lingrong, was originally a servant involved in textile production but, based on a magician's words that she would bear his heir (his sons all having died early by that point), Sima Yu took her as his concubine and she gave birth to Sima Yao. As he was born at dawn, she named him Yao, with the courtesy name Changming, both meaning "dawn". A year later she gave birth to his brother, Sima Daozi. As the oldest surviving son of Sima Yu, Sima Yao was designated as the heir apparent early in his life, and in 365, when he was just three years old, Emperor Fei offered the greater title of Prince of Langye to his father and the title of Prince of Kuaiji to him. Sima Yu declined, both personally and on his son's behalf, and Emperor Fei did not insist on them taking on the greater titles.
In 371, having lost a devastating battle to the Former Yan general Murong Chui in 369, the paramount general Huan Wen accused Emperor Fei of impotence and of not being the biological father of his sons. He then deposed him and made Sima Yu the new emperor (as Emperor Jianwen), although actual power was in Huan's hands. In 372, Emperor Jianwen grew ill and he named Sima Yao crown prince but in his will, he offered the throne to Huan, if he wanted it. When his official Wang Tanzhi (王坦之) objected, Emperor Jianwen gave approval for an amendment, written by Wang, wherein Huan was only compared to the statesmen Zhuge Liang and Wang Dao. Nevertheless, when Emperor Jianwen died, many officials were apprehensive of Huan, and not immediately willing to declare Crown Prince Yao as the new emperor. Finally, at the instigation of Wang Biaozhi (王彪之), Crown Prince Yao took the throne as Emperor Xiaowu.
The new emperor was only 10 years old, therefore his cousin, Empress Dowager Chu (Emperor Kang's wife), served as regent, but the decisions were actually being made by Xie An and Wang Tanzhi; Huan Wen, apparently fearful of being entrapped, declined an offer to be regent. In 373, Huan Wen died and the fears of a Huan usurpation dissipated as his brother and successor, Huan Chong, was committed to the survival of the imperial government.
A major issue for the Jin government was the continued military pressure exerted by the powerful northern rival, Former Qin. In 373, Former Qin attacked and seized Jin's Liang (梁州, modern southern Shaanxi) and Yi (益州, modern Sichuan and Chongqing) provinces. Internally, however, Jin was apparently well-governed by Xie and Huan Chong.
In 375, Emperor Xiaowu married Wang Fahui (the daughter of the official, Wang Yun (王蘊)) as his empress. He was 13 and she was 16. He also started studying the Chinese classic texts and writing poetry. In 376, Empress Dowager Chu officially removed herself from the regent position and returned her powers to Emperor Xiaowu, although the decisions were still largely being made by Xie.
In 376, the Jin vassal, Former Liang, was attacked by Former Qin. Jin forces, under Huan Chong's command, attempted to relieve the pressure on Former Liang by attacking Former Qin, but Former Liang fell quickly and Huan Chong withdrew his forces. In apprehension of a Former Qin attack, Jin evacuated much of its population north of the Huai River to regions south of the river.
In 378, Former Qin made major attacks against the important Jin cities of Xiangyang, Weixing (魏興, in modern Ankang, Shaanxi), and Pengcheng. While general Xie Xuan was able to immediately recapture Pengcheng after it fell, Xiangyang and Weixing were taken by Former Qin forces in 379.
In 380, Empress Wang died. Emperor Xiaowu did not have another empress for the rest of his life.
In 381, Emperor Xiaowu began to study Buddhist sutras and he established a Buddhist study hall inside his palace, inviting monks to live within.
In 383, Huan Chong made a counterattack against Former Qin, hoping to recapture Xiangyang and the southwest. However, after initial losses, Huan abandoned the campaign.
Later in 383, Former Qin's emperor, Fu Jiān, launched a major attack against Jin, intending to destroy it and unite China. At the Battle of Fei River, however, his forces panicked after trying to retreat to draw Jin forces across the river, and his army was routed with great losses, including his brother and prime minister, Fu Rong. Former Qin began to collapse after this defeat and never again posed a threat to Jin.
After defeating Former Qin forces, Xie Xuan spearheaded a campaign to regain lost territory, and Jin captured most of the Former Qin provinces south of the Yellow River, as well as regaining Liang and Yi provinces. However, Prime Minister Xie An, who was most credited with the victory, began to lose favor in Emperor Xiaowu's eyes; Xie's son-in-law, Wang Guobao (王國寶), unhappy that Xie did not give him important posts, began to flatter both Emperor Xiaowu and his brother, Sima Daozi, the Prince of Kuaiji, as a means of undercutting Xie. Xie remained prime minister, however, until his death in 385; he was replaced by Sima Daozi. Both Emperor Xiaowu and Sima became obsessed with feasting and drinking, and neither spent much time on affairs of state.
In 387, Emperor Xiaowu named his oldest son, five-year-old Sima Dezong, crown prince, notwithstanding the fact that Sima was developmentally disabled—so severely that even after he grew older, he was described as not being able to talk, dress himself, or to tell whether he was full or hungry while eating.
In 390, Emperor Xiaowu began to tire of how his brother, Sima Daozi, was taking his favors for granted, and he decided to look for counterbalancing forces. He made the officials Wang Gong (王恭, Empress Wang's brother) and Yin Zhongkan (殷仲堪) key regional governors, despite warnings that both Wang and Yin were talented but narrow-minded, and might create issues later.
By 395, the conflict between Emperor Xiaowu and Sima had flared into the open, but because of the intercession of Empress Dowager Li, Emperor Xiaowu did not remove his brother. After further mediation by Xu Miao (徐邈), the relationship between the brothers seemed to be restored.
By 396, Emperor Xiaowu was spending so much of his time on drinking and women that he was not tending to important matters of state. His favorite consort was the beautiful Honoured Lady Zhang. In late fall 396, when she was almost 30 years old, Emperor joked at a feast saying, "Based on your age, you should yield your position. I want someone younger." That night, after Emperor Xiaowu fell drunk, she ordered all the eunuchs away, bribing them with wine, and then ordered her servant girls to suffocate Emperor Xiaowu by putting a blanket over his face. She further bribed the attendants and claimed that the emperor died suddenly in his sleep. The death was not investigated and the next day, Sima Dezong assumed the throne as Emperor An, with Sima Daozi as regent.Ningkang (寧康 níng kāng) February 19, 373 – February 8, 376
Taiyuan (太元 tài yuán) February 9, 376 – February 12, 397