 His father was Yuan Yu (元羽) the Prince of Guangling, a son of Emperor Xianwen and a brother of Emperor Xiaowen.His mother was Yuan Yu's concubine Lady Wang.In 501, during the reign of Emperor Xiaowen's son Emperor Xuanwu, Yuan Yu died from injuries he suffered when he was attacked by his lover's husband, the low level official, Feng Junxing (馮俊興), and for reasons unclear, Yuan Gong inherited Yuan Yu's title even though he had one older brother, Yuan Xin (元欣), and neither he nor Yuan Xin was the son of Yuan Yu's wife Princess Zheng Shirong (郑始容).