Huan Xuan was born in 369, as the youngest son of Huan Wen, then the paramount general of Jin, and his wife, Sima Xingnan (司馬興男) the Princess of Nankang, the daughter of Emperor Ming of Jin. (An alternative account has him as born of Huan Wen's concubine Lady Ma.) When Huan Wen died in 373, his title should have gone to his heir apparent Huan Xi (桓熙), his oldest son. However, Huan Chong, Huan Wen's brother whom Huan Wen entrusted the command of the army to, believed (correctly) that Huan Xi was in a plot with another brother of Huan Wen's, Huan Mi (桓秘), and another son of Huan Wen's, Huan Ji (桓濟), to assassinate him and take power, and so detained Huan Xi, Huan Ji, and Huan Mi. Instead, he declared that it was Huan Wen's desire that his title be passed to Huan Xuan, and so Huan Xuan, at age four, inherited the title of Duke of Nan Commandery, with the dukedom roughly corresponding to modern Jingzhou, Hubei.