Sima Pi was born in 341, during the reign of his father Emperor Cheng of Jin, as Emperor Cheng's oldest son. His mother was , who in 342 gave birth to his younger brother . In summer 342, Emperor Cheng grew ill. The common succession protocol, as He Chong pointed out, would mean that his oldest son would succeed to the throne, but Emperor Cheng's uncle Yu Bing , wanting a new emperor who would also be connected to his clan as well, persuaded Emperor Cheng to pass the throne to his younger brother the Prince of Langye, also a son of his sister Empress Yu Wenjun, under the reasoning that with the powerful rival Later Zhao to the north, the empire needed an adult emperor. Emperor Cheng agreed, and named Sima Yue as the heir, and Sima Yue succeeded to the throne as Emperor Kang when he died soon after. The one-year-old Sima Pi was instead created the Prince of Langye. He continued in that title after Emperor Kang's death in 344, as Emperor Kang chose to pass the throne to his infant son . It is not known when he married his wife , only that she carried the title Princess of Langye.
In 361, Emperor Mu died without a son. Emperor Mu's mother thus ordered that Sima Pi be made emperor, and he took the throne as Emperor Ai, at age 20. He created his wife Princess Wang as empress, and his brother Sima Yi, who previously carried the title the Prince of Donghai, as the Prince of Langye. Since he was an adult, Empress Dowager Chu did not serve as regent for him, and he honored his mother Consort Zhou as Consort Dowager in 362, but with supplies and ceremonies similar to the empress dowager. However, the decision-making process was largely in the hands of the general Huan Wen and Emperor Ai's granduncle the Prince of Kuaiji.
In 362, Huan, after securing the Luoyang region, requested that the capital be moved back to Luoyang, where it had been until it was captured by Han Zhao in 311. The imperial government, under an edict issued by Emperor Ai, declined.
In 363, Consort Dowgaer Zhou died. In accordance with proper protocol that he could no longer honor her as mother, out of respect for Empress Dowgaer Chu, Emperor Ai did not observe the normal mourning period due a mother.
Emperor Ai was obsessed with seeking immortality, despite his young age. In 364, he became poisoned by pills given him by magicians, and he grew so ill that he was unable to handle important matters. Empress Dowager Chu had to resume on his behalf.
Later in 364, Former Yan launched a major attack against Luoyang, and Huan and Sima Yu considered a counterattack to relieve Luoyang. However, as Emperor Ai died in early 365, that plan was cancelled, and Luoyang soon fell. As he did not have a son, Emperor Ai was succeeded by his brother Sima Yi, as Emperor Fei.
* ''Longhe'' March 2 362-February 5, 363
* ''Xingning'' February 6, 363-365
** Emperor Cheng of Jin
** Empress Wang Muzhi